X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Funix.c;h=3449001059de76e92b569a479fe792f3481b1421;hb=185028bccf8a5e6635fc5ef8f1f737c798e29c2a;hp=c67b724cd90d7e8af9de8b2602df57f5b6054e69;hpb=31e3a0ef5a0866477a3b54dc6ffbeb0aca4e0029;p=yaz-moved-to-github.git diff --git a/src/unix.c b/src/unix.c index c67b724..3449001 100644 --- a/src/unix.c +++ b/src/unix.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: unix.c,v 1.11 2005-02-01 14:37:47 adam Exp $ + * $Id: unix.c,v 1.14 2005-02-09 09:18:27 adam Exp $ * UNIX socket COMSTACK. By Morten Bøgeskov. */ /** @@ -313,6 +313,7 @@ static int unix_connect(COMSTACK h, void *address) { struct sockaddr_un *add = (struct sockaddr_un *)address; int r; + int i; TRC(fprintf(stderr, "unix_connect\n")); h->io_pending = 0; @@ -321,14 +322,28 @@ static int unix_connect(COMSTACK h, void *address) h->cerrno = CSOUTSTATE; return -1; } - r = connect(h->iofile, (struct sockaddr *) add, SUN_LEN(add)); + for (i = 0; i<3; i++) + { + r = connect(h->iofile, (struct sockaddr *) add, SUN_LEN(add)); + if (r < 0 && yaz_errno() == EAGAIN) + { +#if HAVE_USLEEP + usleep(i*10000+1000); /* 1ms, 11ms, 21ms */ +#else + sleep(1); +#endif + continue; + } + else + break; + } if (r < 0) { if (yaz_errno() == EINPROGRESS) { h->event = CS_CONNECT; h->state = CS_ST_CONNECTING; - h->io_pending = CS_WANT_WRITE|CS_WANT_READ; + h->io_pending = CS_WANT_WRITE; return 1; } h->cerrno = CSYSERR; @@ -405,7 +420,7 @@ static int unix_bind(COMSTACK h, void *address, int mode) } chown(path, sp->uid, sp->gid); chmod(path, sp->umask != -1 ? sp->umask : 0666); - if (mode == CS_SERVER && listen(h->iofile, 3) < 0) + if (mode == CS_SERVER && listen(h->iofile, 100) < 0) { h->cerrno = CSYSERR; return -1;