* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: unix.c,v 1.9 2003-01-06 08:20:27 adam Exp $
+ * $Id: unix.c,v 1.14 2003-10-08 21:47:15 adam Exp $
* UNIX socket COMSTACK. By Morten Bøgeskov.
*/
#ifndef WIN32
#include <yaz/comstack.h>
#include <yaz/unix.h>
#include <yaz/log.h>
-
-/* Chas added the following, so we get the definition of completeBER */
-#include <yaz/odr.h>
+#include <yaz/nmem.h>
#ifndef YAZ_SOCKLEN_T
#define YAZ_SOCKLEN_T int
void *cd);
static int unix_set_blocking(COMSTACK p, int blocking);
-
static COMSTACK unix_accept(COMSTACK h);
static char *unix_addrstr(COMSTACK h);
static void *unix_straddr(COMSTACK h, const char *str);
xmalloc(sizeof(unix_state)))))
return 0;
- if (!(p->blocking = blocking))
+ if (!((p->blocking = blocking)&1))
{
if (fcntl(s, F_SETFL, O_NONBLOCK) < 0)
return 0;
if (protocol == PROTO_WAIS)
state->complete = completeWAIS;
else
- state->complete = completeBER;
+ state->complete = cs_complete_auto;
p->timeout = COMSTACK_DEFAULT_TIMEOUT;
TRC(fprintf(stderr, "Created new UNIX comstack\n"));
h->cerrno = CSYSERR;
return -1;
}
+ chmod(path, 0777);
if (mode == CS_SERVER && listen(h->iofile, 3) < 0)
{
h->cerrno = CSYSERR;
void *cd)
{
struct sockaddr_un addr;
- YAZ_SOCKLEN_T len = SUN_LEN(&addr);
+ YAZ_SOCKLEN_T len = sizeof(addr);
TRC(fprintf(stderr, "unix_listen pid=%d\n", getpid()));
if (h->state != CS_ST_IDLE)
}
return 0;
}
- if (!cnew->blocking &&
- (!cnew->blocking && fcntl(cnew->iofile, F_SETFL, O_NONBLOCK) < 0)
+ if (!(cnew->blocking&1) &&
+ (fcntl(cnew->iofile, F_SETFL, O_NONBLOCK) < 0)
)
{
h->cerrno = CSYSERR;
state->altsize = state->altlen = 0;
state->towrite = state->written = -1;
state->complete = st->complete;
+ memcpy(&state->addr, &st->addr, sizeof(state->addr));
cnew->state = CS_ST_ACCEPT;
cnew->event = CS_NONE;
h->state = CS_ST_IDLE;