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
* (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
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
* 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
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 =
}
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<no; i++)
{
ZOOM_connection c = cs[i];
- ZOOM_Event event;
-#if 0
- if (c)
- ZOOM_connection_show_tasks(c);
-#endif
-
- if (c && (event = ZOOM_connection_get_event(c)))
- {
- ZOOM_Event_destroy(event);
+ if (c && ZOOM_connection_process(c))
return i+1;
- }
- }
- for (i = 0; i<no; i++)
- {
- ZOOM_connection c = cs[i];
- if (c)
- {
- ZOOM_Event event;
- ZOOM_connection_exec_task(c);
- if ((event = ZOOM_connection_get_event(c)))
- {
- ZOOM_Event_destroy(event);
- return i+1;
- }
- }
}
return 0;
}
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: zoom-socket.c,v 1.1 2007-01-09 13:56:48 adam Exp $
+ * $Id: zoom-socket.c,v 1.2 2007-01-12 21:03:31 adam Exp $
*/
/**
* \file zoom-socket.c
{
int r;
- r = ZOOM_process_event(no, cs);
+ r = ZOOM_event_nonblock(no, cs);
if (r)
return r;
#if HAVE_SYS_POLL_H
#else
ZOOM_event_sys_select(no, cs);
#endif
- return ZOOM_process_event(no, cs);
+ return ZOOM_event_nonblock(no, cs);
}
/*