X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fzoom-socket.c;h=36a5f15768509e3a1177f8d2d6db668bab362dbe;hp=da72edafa32b52dbb431a30dea5c290d6be8f6ad;hb=d7cba4993e5c7c06c655d9a1d903f889fdee8329;hpb=8b4a08403ae705e22b604bffa4577ac403b7de8d diff --git a/src/zoom-socket.c b/src/zoom-socket.c index da72eda..36a5f15 100644 --- a/src/zoom-socket.c +++ b/src/zoom-socket.c @@ -1,13 +1,14 @@ -/* - * Copyright (C) 1995-2007, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) Index Data * See the file LICENSE for details. - * - * $Id: zoom-socket.c,v 1.5 2007-11-09 16:46:43 adam Exp $ */ /** * \file zoom-socket.c * \brief Implements ZOOM C socket interface. */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -29,7 +30,7 @@ ZOOM_API(int) ZOOM_event_sys_yaz_poll(int no, ZOOM_connection *cs) { - struct yaz_poll_fd *yp = xmalloc(sizeof(*yp) * no); + struct yaz_poll_fd *yp = (struct yaz_poll_fd *) xmalloc(sizeof(*yp) * no); int i, r; int nfds = 0; int timeout = 30; @@ -38,7 +39,7 @@ ZOOM_API(int) { ZOOM_connection c = cs[i]; int fd, mask; - + if (!c) continue; fd = ZOOM_connection_get_socket(c); @@ -49,14 +50,14 @@ ZOOM_API(int) continue; if (mask) { - enum yaz_poll_mask input_mask = 0; + enum yaz_poll_mask input_mask = yaz_poll_none; if (mask & ZOOM_SELECT_READ) - input_mask += yaz_poll_read; + yaz_poll_add(input_mask, yaz_poll_read); if (mask & ZOOM_SELECT_WRITE) - input_mask += yaz_poll_write; + yaz_poll_add(input_mask, yaz_poll_write); if (mask & ZOOM_SELECT_EXCEPT) - input_mask += yaz_poll_except; + yaz_poll_add(input_mask, yaz_poll_except); yp[nfds].fd = fd; yp[nfds].input_mask = input_mask; yp[nfds].client_data = c; @@ -68,12 +69,12 @@ ZOOM_API(int) xfree(yp); return 0; } - r = yaz_poll(yp, nfds, timeout); + r = yaz_poll(yp, nfds, timeout, 0); if (r >= 0) { for (i = 0; i < nfds; i++) { - ZOOM_connection c = yp[i].client_data; + ZOOM_connection c = (ZOOM_connection) yp[i].client_data; enum yaz_poll_mask output_mask = yp[i].output_mask; if (output_mask & yaz_poll_timeout) ZOOM_connection_fire_event_timeout(c); @@ -102,13 +103,15 @@ ZOOM_API(int) r = ZOOM_event_nonblock(no, cs); if (r) return r; - ZOOM_event_sys_yaz_poll(no, cs); + while (ZOOM_event_sys_yaz_poll(no, cs) < 0 && errno == EINTR) + ; return ZOOM_event_nonblock(no, cs); } /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab