< prev index next >

src/os/aix/vm/attachListener_aix.cpp

Print this page
rev 11747 : 8162869: Small fixes for AIX perf memory and attach listener


 366       return NULL;
 367     }
 368     s=::accept(listener(), &addr, &len);
 369     if (s == -1) {
 370       return NULL;      // log a warning?
 371     }
 372 
 373     // Added timeouts for read and write.  If we get no request within the
 374     // next AttachListenerTimeout milliseconds we just finish the connection.
 375     struct timeval tv;
 376     tv.tv_sec = 0;
 377     tv.tv_usec = AttachListenerTimeout * 1000;
 378     ::setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char*)&tv, sizeof(tv));
 379     ::setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (char*)&tv, sizeof(tv));
 380 
 381     // get the credentials of the peer and check the effective uid/guid
 382     // - check with jeff on this.
 383     struct peercred_struct cred_info;
 384     socklen_t optlen = sizeof(cred_info);
 385     if (::getsockopt(s, SOL_SOCKET, SO_PEERID, (void*)&cred_info, &optlen) == -1) {
 386       int res;
 387       RESTARTABLE(::close(s), res);
 388       continue;
 389     }
 390     uid_t euid = geteuid();
 391     gid_t egid = getegid();
 392 
 393     if (cred_info.euid != euid || cred_info.egid != egid) {
 394       int res;
 395       RESTARTABLE(::close(s), res);
 396       continue;
 397     }
 398 
 399     // peer credential look okay so we read the request
 400     AixAttachOperation* op = read_request(s);
 401     if (op == NULL) {
 402       int res;
 403       ::close(s);
 404       continue;
 405     } else {
 406       return op;
 407     }
 408   }
 409 }
 410 
 411 // write the given buffer to the socket
 412 int AixAttachListener::write_fully(int s, char* buf, int len) {
 413   do {
 414     int n = ::write(s, buf, len);
 415     if (n == -1) {
 416       if (errno != EINTR) return -1;
 417     } else {
 418       buf += n;
 419       len -= n;
 420     }
 421   }
 422   while (len > 0);




 366       return NULL;
 367     }
 368     s=::accept(listener(), &addr, &len);
 369     if (s == -1) {
 370       return NULL;      // log a warning?
 371     }
 372 
 373     // Added timeouts for read and write.  If we get no request within the
 374     // next AttachListenerTimeout milliseconds we just finish the connection.
 375     struct timeval tv;
 376     tv.tv_sec = 0;
 377     tv.tv_usec = AttachListenerTimeout * 1000;
 378     ::setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char*)&tv, sizeof(tv));
 379     ::setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (char*)&tv, sizeof(tv));
 380 
 381     // get the credentials of the peer and check the effective uid/guid
 382     // - check with jeff on this.
 383     struct peercred_struct cred_info;
 384     socklen_t optlen = sizeof(cred_info);
 385     if (::getsockopt(s, SOL_SOCKET, SO_PEERID, (void*)&cred_info, &optlen) == -1) {
 386       ::close(s);

 387       continue;
 388     }
 389     uid_t euid = geteuid();
 390     gid_t egid = getegid();
 391 
 392     if (cred_info.euid != euid || cred_info.egid != egid) {
 393       ::close(s);

 394       continue;
 395     }
 396 
 397     // peer credential look okay so we read the request
 398     AixAttachOperation* op = read_request(s);
 399     if (op == NULL) {

 400       ::close(s);
 401       continue;
 402     } else {
 403       return op;
 404     }
 405   }
 406 }
 407 
 408 // write the given buffer to the socket
 409 int AixAttachListener::write_fully(int s, char* buf, int len) {
 410   do {
 411     int n = ::write(s, buf, len);
 412     if (n == -1) {
 413       if (errno != EINTR) return -1;
 414     } else {
 415       buf += n;
 416       len -= n;
 417     }
 418   }
 419   while (len > 0);


< prev index next >