X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=comstack%2Funix.c;h=960ccec437a738f711f7a94f353dc5f23cfee10d;hb=366dc7568281c9774cd309b28c24a077604264a0;hp=edfa830a23496905c483e0c2a56cc9cbf50894d4;hpb=ca4948d9b8ea1e4d73d25a25b1da3a4de121ca73;p=yaz-moved-to-github.git diff --git a/comstack/unix.c b/comstack/unix.c index edfa830..960ccec 100644 --- a/comstack/unix.c +++ b/comstack/unix.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2002, Index Data * See the file LICENSE for details. * - * $Id: unix.c,v 1.5 2002-09-10 20:56:34 adam Exp $ + * $Id: unix.c,v 1.7 2002-09-25 12:37:07 adam Exp $ * UNIX socket COMSTACK. By Morten Bøgeskov. */ #ifndef WIN32 @@ -26,14 +26,8 @@ /* Chas added the following, so we get the definition of completeBER */ #include -#if HAVE_SOCKLEN_T -#define NET_LEN_T socklen_t -#else -#if GETPEERNAME_ACCEPTS_SIZE_T_FOR_THIRD_ARGUMENT -#define NET_LEN_T size_t -#else -#define NET_LEN_T int -#endif +#ifndef YAZ_SOCKLEN_T +#define YAZ_SOCKLEN_T int #endif int unix_close(COMSTACK h); @@ -219,7 +213,7 @@ int unix_connect(COMSTACK h, void *address) r = connect(h->iofile, (struct sockaddr *) add, SUN_LEN(add)); if (r < 0) { - if (errno == EINPROGRESS) + if (yaz_errno() == EINPROGRESS) { h->event = CS_CONNECT; h->state = CS_ST_CONNECTING; @@ -270,7 +264,7 @@ int unix_bind(COMSTACK h, void *address, int mode) int socket_out = -1; if(! S_ISSOCK(stat_buf.st_mode)) { h->cerrno = CSYSERR; - errno = EEXIST; /* Not a socket (File exists) */ + yaz_set_errno(EEXIST); /* Not a socket (File exists) */ return -1; } if((socket_out = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { @@ -280,7 +274,7 @@ int unix_bind(COMSTACK h, void *address, int mode) socket_unix.sun_family = AF_UNIX; strncpy(socket_unix.sun_path, path, sizeof(socket_unix.sun_path)); if(connect(socket_out, (struct sockaddr *) &socket_unix, SUN_LEN(&socket_unix)) < 0) { - if(errno == ECONNREFUSED) { + if(yaz_errno() == ECONNREFUSED) { TRC (fprintf (stderr, "Socket exists but nobody is listening\n")); } else { h->cerrno = CSYSERR; @@ -289,7 +283,7 @@ int unix_bind(COMSTACK h, void *address, int mode) } else { close(socket_out); h->cerrno = CSYSERR; - errno = EADDRINUSE; + yaz_set_errno(EADDRINUSE); return -1; } unlink(path); @@ -315,7 +309,7 @@ int unix_listen(COMSTACK h, char *raddr, int *addrlen, void *cd) { struct sockaddr_un addr; - NET_LEN_T len = SUN_LEN(&addr); + YAZ_SOCKLEN_T len = SUN_LEN(&addr); TRC(fprintf(stderr, "unix_listen pid=%d\n", getpid())); if (h->state != CS_ST_IDLE) @@ -327,10 +321,10 @@ int unix_listen(COMSTACK h, char *raddr, int *addrlen, if (h->newfd < 0) { if ( - errno == EWOULDBLOCK + yaz_errno() == EWOULDBLOCK #ifdef EAGAIN #if EAGAIN != EWOULDBLOCK - || errno == EAGAIN + || yaz_errno() == EAGAIN #endif #endif ) @@ -457,19 +451,19 @@ int unix_get(COMSTACK h, char **buf, int *bufsize) TRC(fprintf(stderr, " recv res=%d, hasread=%d\n", res, hasread)); if (res < 0) { - if (errno == EWOULDBLOCK + if (yaz_errno() == EWOULDBLOCK #ifdef EAGAIN #if EAGAIN != EWOULDBLOCK - || errno == EAGAIN + || yaz_errno() == EAGAIN #endif #endif - || errno == EINPROGRESS + || yaz_errno() == EINPROGRESS ) { h->io_pending = CS_WANT_READ; break; } - else if (errno == 0) + else if (yaz_errno() == 0) continue; else return -1; @@ -541,10 +535,10 @@ int unix_put(COMSTACK h, char *buf, int size) )) < 0) { if ( - errno == EWOULDBLOCK + yaz_errno() == EWOULDBLOCK #ifdef EAGAIN #if EAGAIN != EWOULDBLOCK - || errno == EAGAIN + || yaz_errno() == EAGAIN #endif #endif )