1#include "syshdrs.h" 2#ifdef PRAGMA_HDRSTOP 3# pragma hdrstop 4#endif 5 6#ifdef HAVE_SYS_UN_H 7 8int 9UAccept(int sfd, struct sockaddr_un *const addr, int *ualen, int tlen) 10{ 11 int result; 12 fd_set ss; 13 struct timeval tv; 14 sockaddr_size_t ualen2; 15 DECL_SIGPIPE_VARS 16 17 if (addr == NULL) { 18 errno = EINVAL; 19 return (-1); 20 } 21 22 IGNORE_SIGPIPE 23 24 if (tlen <= 0) { 25 errno = 0; 26 for (;;) { 27 ualen2 = (sockaddr_size_t) sizeof(struct sockaddr_un); 28 result = accept(sfd, (struct sockaddr *) addr, &ualen2); 29 if (ualen != NULL) 30 *ualen = (int) ualen2; 31 if ((result >= 0) || (errno != EINTR)) { 32 RESTORE_SIGPIPE 33 return (result); 34 } 35 } 36 } 37 38 for (;;) { 39 errno = 0; 40 MY_FD_ZERO(&ss); 41#if defined(__DECC) || defined(__DECCXX) 42#pragma message save 43#pragma message disable trunclongint 44#endif 45 MY_FD_SET(sfd, &ss); 46#if defined(__DECC) || defined(__DECCXX) 47#pragma message restore 48#endif 49 tv.tv_sec = (tv_sec_t) tlen; 50 tv.tv_usec = 0; 51 result = select(sfd + 1, SELECT_TYPE_ARG234 &ss, NULL, NULL, &tv); 52 if (result >= 1) { 53 /* ready */ 54 break; 55 } else if (result == 0) { 56 /* timeout */ 57 errno = ETIMEDOUT; 58 RESTORE_SIGPIPE 59 return (kTimeoutErr); 60 } else if (errno != EINTR) { 61 RESTORE_SIGPIPE 62 return (-1); 63 } 64 } 65 66 do { 67 ualen2 = (sockaddr_size_t) sizeof(struct sockaddr_un); 68 result = accept(sfd, (struct sockaddr *) addr, &ualen2); 69 if (ualen != NULL) 70 *ualen = (int) ualen2; 71 } while ((result < 0) && (errno == EINTR)); 72 73 RESTORE_SIGPIPE 74 return (result); 75} /* UAccept */ 76 77#endif /* HAVE_SYS_UN_H */ 78