On 07/22/2011 06:15 PM, Michal Hocko wrote:
> On Fri 22-07-11 09:06:59, Nikiforov Alex wrote:
>> @@ -3704,6 +3705,7 @@ int cgroup_register_unchanged_process(pid_t pid,
>> int flags)
>>      int ret = 1;
>>      char buff[sizeof(CGRULE_SUCCESS_STORE_PID)];
>>      struct sockaddr_un addr;
>> +    struct iovec    iov[2] = {};
>>
>>      sk = socket(PF_UNIX, SOCK_STREAM, 0);
>>      if (sk<  0)
>> @@ -3720,10 +3722,13 @@ int cgroup_register_unchanged_process(pid_t pid,
>> int flags)
>>              ret = 0;
>>              goto close;
>>      }
>> -    if (write(sk,&pid, sizeof(pid))<  0)
>> -            goto close;
>>
>> -    if (write(sk,&flags, sizeof(flags))<  0)
>> +    iov[0].iov_base =&pid;
>> +    iov[0].iov_len =  sizeof(pid);
>> +    iov[1].iov_base =&flags;
>> +    iov[1].iov_len =  sizeof(flags);
>> +
>> +    if (writev(sk, iov, 2)<  0)
>>              goto close;
>
> shouldn't you check for<  iov[0].iov_len + iov[1].iov_len?
>
>>
>>      if (read(sk, buff, sizeof(buff))<  0)
>> diff --git a/src/daemon/cgrulesengd.c b/src/daemon/cgrulesengd.c
>> index 2f42a57..14887bb 100644
>> --- a/src/daemon/cgrulesengd.c
>> +++ b/src/daemon/cgrulesengd.c
>> @@ -40,6 +40,7 @@
>>    #include<stdio.h>
>>    #include<stdlib.h>
>>    #include<sys/socket.h>
>> +#include<sys/uio.h>
>>    #include<sys/syslog.h>
>>    #include<string.h>
>>    #include<linux/netlink.h>
>> @@ -552,6 +553,7 @@ static void cgre_receive_unix_domain_msg(int sk_unix)
>>      socklen_t caddr_len;
>>      struct stat buff_stat;
>>      char path[FILENAME_MAX];
>> +    struct iovec    iov[2] = {};
>>
>>      caddr_len = sizeof(caddr);
>>      fd_client = accept(sk_unix, (struct sockaddr *)&caddr,&caddr_len);
>> @@ -559,16 +561,19 @@ static void cgre_receive_unix_domain_msg(int sk_unix)
>>              cgroup_dbg("accept error: %s\n", strerror(errno));
>>              return;
>>      }
>> -    if (read(fd_client,&pid, sizeof(pid))<  0) {
>> -            cgroup_dbg("read error: %s\n", strerror(errno));
>> -            goto close;
>> -    }
>> -    sprintf(path, "/proc/%d", pid);
>> -    if (stat(path,&buff_stat)) {
>> -            cgroup_dbg("There is not such process (PID: %d)", pid);
>> -            goto close;
>> -    }
>> -    if (read(fd_client,&flags, sizeof(flags))<  0) {
>> +
>> +    iov[0].iov_base =&pid;
>> +    iov[0].iov_len =  sizeof(pid);
>> +    iov[1].iov_base =&flags;
>> +    iov[1].iov_len =  sizeof(flags);
>> +
>> +    if (readv(fd_client, iov, 2)<  0) {
>
> Same here.

1) Dont think that's point here, we are on local iface and we write/read 
just few bytes. For me it's hardly to figure that in this place we can 
get EAGAIN. BTW look at previous code, it's twice harder in syscall and 
seems that you dont have any trouble with it


------------------------------------------------------------------------------
Storage Efficiency Calculator
This modeling tool is based on patent-pending intellectual property that
has been used successfully in hundreds of IBM storage optimization engage-
ments, worldwide.  Store less, Store more with what you own, Move data to 
the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to