From: Adam Dickmeiss Date: Fri, 12 Jan 2007 21:03:30 +0000 (+0000) Subject: Renamed ZOOM_process_event to ZOOM_event_nonblock to signal that it X-Git-Tag: YAZ.2.1.46~3 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=0982c13b874d79d950800b62ea22d91d943f3036;p=yaz-moved-to-github.git Renamed ZOOM_process_event to ZOOM_event_nonblock to signal that it it is the non-blocking part of ZOOM_event. Added per-connection version called ZOOM_connecton_process which is used by implementation of ZOOM_event_nonblock. --- diff --git a/NEWS b/NEWS index 556e1f0..b7fad13 100644 --- a/NEWS +++ b/NEWS @@ -4,7 +4,7 @@ Added ZOOM_connection_peek_event. Implemented Generic select hook for ZOOM (bug #803). This is achieved with the following new functions: - ZOOM_process_event, + ZOOM_event_nonblock, ZOOM_connection_process, ZOOM_connection_get_{socket,mask,timeout}, ZOOM_connection_fire_event_{timeout,socket}. The existing blocking event handler, ZOOM_event, is a wrapper for the diff --git a/include/yaz/zoom.h b/include/yaz/zoom.h index 3295eb0..8dcbcf6 100644 --- a/include/yaz/zoom.h +++ b/include/yaz/zoom.h @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: zoom.h,v 1.43 2007-01-10 13:25:46 adam Exp $ */ +/* $Id: zoom.h,v 1.44 2007-01-12 21:03:30 adam Exp $ */ /** * \file zoom.h @@ -370,21 +370,38 @@ ZOOM_API(int) ZOOM_connection_is_idle(ZOOM_connection c); -/** \brief processes one event for one of connections given +/** \brief process one event for one of connections given \param no number of connections (size of cs) \param cs connection array \retval 0 no event was processed \retval >0 event was processed for connection at (retval-1) + This function attemps to deal with outstandings events in a non-blocking + mode. If no events was processed (return value of 0), then the system + should attempt to deal with sockets in blocking mode using socket + select/poll which means calling the following functions: + ZOOM_connection_get_socket, ZOOM_connection_get_mask, + ZOOM_connection_get_timeout. +*/ +ZOOM_API(int) + ZOOM_event_nonblock(int no, ZOOM_connection *cs); + + +/** \brief process one event for connection + \param c connection + \retval 0 no event was processed + \retval 1 event was processed for connection + This function attemps to deal with outstandings events in - a non-blocking fashion. If no events was processed (return value of 0), + a non-blocking fashion. If no event was processed (return value of 0), then the system should attempt to deal with sockets in blocking mode using socket select/poll which means calling the following functions: ZOOM_connection_get_socket, ZOOM_connection_get_mask, - ZOOM_connection_get_timeout. + ZOOM_connection_get_timeout. If an event was processed call this + function again. */ ZOOM_API(int) - ZOOM_process_event(int no, ZOOM_connection *cs); + ZOOM_connection_process(ZOOM_connection c); /** \brief get socket fd for ZOOM connection diff --git a/src/zoom-c.c b/src/zoom-c.c index 54b41eb..15047d4 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.107 2007-01-11 11:05:01 adam Exp $ + * $Id: zoom-c.c,v 1.108 2007-01-12 21:03:31 adam Exp $ */ /** * \file zoom-c.c @@ -1250,7 +1250,7 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c) odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.107 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.108 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = @@ -4125,41 +4125,41 @@ ZOOM_API(int) ZOOM_connection_fire_event_timeout(ZOOM_connection c) } ZOOM_API(int) - ZOOM_process_event(int no, ZOOM_connection *cs) + ZOOM_connection_process(ZOOM_connection c) +{ + ZOOM_Event event; + if (!c) + return 0; + + event = ZOOM_connection_get_event(c); + if (event) + { + ZOOM_Event_destroy(event); + return 1; + } + ZOOM_connection_exec_task(c); + event = ZOOM_connection_get_event(c); + if (event) + { + ZOOM_Event_destroy(event); + return 1; + } + return 0; +} + +ZOOM_API(int) + ZOOM_event_nonblock(int no, ZOOM_connection *cs) { int i; - yaz_log(log_details, "ZOOM_event_poll(no=%d,cs=%p)", no, cs); + yaz_log(log_details, "ZOOM_process_event(no=%d,cs=%p)", no, cs); for (i = 0; i