On 11/26/2012 03:59 AM, Ulrich Windl wrote:
> Hi!
> 
> The "goto" looks ugly and not necessary.

Yeah, probably putting the systemd detection in a function then calling
it from mgmt_ipc_listen would be nicer.


> 
> Regards,
> Ulrich
> 
>> --->>> Tomasz Torcz <to...@pipebreaker.pl> schrieb am 21.11.2012 um 13:50 in 
>> Nachricht 
> <1353502230-24613-2-git-send-email-to...@pipebreaker.pl>:
> 
>>  usr/mgmt_ipc.c | 22 ++++++++++++++++++++++ 
>>  1 file changed, 22 insertions(+) 
>>  
>> diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c 
>> index 36f5d02..90dddbe 100644 
>> --- a/usr/mgmt_ipc.c 
>> +++ b/usr/mgmt_ipc.c 
>> @@ -39,13 +39,35 @@ 
>>   
>>  #define PEERUSER_MAX        64 
>>  #define EXTMSG_MAX  (64 * 1024) 
>> +#define SD_SOCKET_FDS_START 3 
>>   
>>  int 
>>  mgmt_ipc_listen(void) 
>>  { 
>>      int fd, err; 
>>      struct sockaddr_un addr; 
>> +    const char *env; 
>>   
>> +    /* first check if we have fd handled by systemd */ 
>> +    env = getenv("LISTEN_PID"); 
>> + 
>> +    if (!env || (strtoul(env, NULL, 10) != getpid())) 
>> +            goto manual; 
>> + 
>> +    env = getenv("LISTEN_FDS"); 
>> + 
>> +    if (!env) 
>> +            goto manual; 
>> + 
>> +    if (strtoul(env, NULL, 10) != 1) { 
>> +            log_error("Did not receive exactly one IPC socket from 
>> systemd"); 
>> +            return -EINVAL; 
>> +    } 
>> + 
>> +    return SD_SOCKET_FDS_START;  
>> +     
>> +manual: 
>> +    /* manually establish a socket */ 
>>      fd = socket(AF_LOCAL, SOCK_STREAM, 0); 
>>      if (fd < 0) { 
>>              log_error("Can not create IPC socket"); 
> 
> 
> 
>  
> 

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to