pcp
[Top] [All Lists]

Re: [pcp] PCP Updates: Consolidate Code for Obtaining Port Numbers From

To: pcp@xxxxxxxxxxx
Subject: Re: [pcp] PCP Updates: Consolidate Code for Obtaining Port Numbers From the Environment and From Strings
From: Dave Brolley <brolley@xxxxxxxxxx>
Date: Thu, 29 May 2014 11:58:09 -0400
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <53862EA9.3080601@xxxxxxxxxx>
References: <53862EA9.3080601@xxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
Some rework of the internal __pm*AddPorts() API functions based on irc comments from fche.

In addition to the items addressed below, Frank was concerned about these functions (via __pmAddPorts) using __pmNoMem and not returning for memory allocation errors. He would prefer that -ENOMEM be returned, leaving the ultimate decision of whether to terminate up to the app. I left this as-is for now. Leaving things as they are accomplishes my goal of consolidating this code while leaving the behaviour of the callers unaffected. Also, this is an allocation of an additional 4 bytes. If it fails, it is unlikely that any app will be able to continue anyway.

Frank also wondered about the layering of the API functions. __pmServiceAddPorts() is useful for applications like pmfind that don't directly know or care to know which service they are contacting. The __pm<service>AddPorts() variants are for the actual clients or servers to use, since they know exactly who they are or who they are dealing with. They also encapsulate the source of the port information (i.e. environment variables). Finally __pmAddPorts() is the work horse used by all of the above.

Pushed to the brolley/dev branch of pcpfans.

Dave
---------------------------------------------------------------------------------------

commit 83f5777e4f713b8614f549987d4fd25085c6910a
Author: Dave Brolley <brolley@xxxxxxxxxx>
Date:   Thu May 29 11:44:20 2014 -0400

    Some rework of the internal __pm*AddPorts() API functions.

    - Commented on the caller's responsibility for freeing
      (re)allocated memory.
    - Eliminated two obsolete static 'first_time' flags.

<Prev in Thread] Current Thread [Next in Thread>