qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cliffjan...@apache.org
Subject qpid-proton git commit: Windows API catchup for selectables: 0cf97bb
Date Tue, 20 Jan 2015 14:56:53 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master 4283872aa -> 43384c15e


Windows API catchup for selectables: 0cf97bb


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/43384c15
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/43384c15
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/43384c15

Branch: refs/heads/master
Commit: 43384c15e6fe3009abddac63533a37d0fa6c12f9
Parents: 4283872
Author: Clifford Jansen <cliffjansen@apache.org>
Authored: Tue Jan 20 06:55:23 2015 -0800
Committer: Clifford Jansen <cliffjansen@apache.org>
Committed: Tue Jan 20 06:55:23 2015 -0800

----------------------------------------------------------------------
 proton-c/src/windows/driver.c   | 123 ++++++-----------------------------
 proton-c/src/windows/selector.c |  14 ++--
 2 files changed, 25 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/43384c15/proton-c/src/windows/driver.c
----------------------------------------------------------------------
diff --git a/proton-c/src/windows/driver.c b/proton-c/src/windows/driver.c
index d446aae..996caac 100644
--- a/proton-c/src/windows/driver.c
+++ b/proton-c/src/windows/driver.c
@@ -127,42 +127,6 @@ static void get_new_events(pn_driver_t *);
 
 // listener
 
-static void driver_listener_readable(pn_selectable_t *sel)
-{
-  // do nothing
-}
-
-static void driver_listener_writable(pn_selectable_t *sel)
-{
-  // do nothing
-}
-
-static void driver_listener_expired(pn_selectable_t *sel)
-{
-  // do nothing
-}
-
-static ssize_t driver_listener_capacity(pn_selectable_t *sel)
-{
-  return 1;
-}
-
-static ssize_t driver_listener_pending(pn_selectable_t *sel)
-{
-  return 0;
-}
-
-static pn_timestamp_t driver_listener_deadline(pn_selectable_t *sel)
-{
-  return 0;
-}
-
-static void driver_listener_finalize(pn_selectable_t *sel)
-{
-  // do nothing
-}
-
-
 static void pn_driver_add_listener(pn_driver_t *d, pn_listener_t *l)
 {
   if (!l->driver) return;
@@ -228,14 +192,9 @@ pn_listener_t *pn_listener_fd(pn_driver_t *driver, pn_socket_t fd, void
*context
   l->pending = false;
   l->closed = false;
   l->context = context;
-  l->selectable = pni_selectable(driver_listener_capacity,
-                                 driver_listener_pending,
-                                 driver_listener_deadline,
-                                 driver_listener_readable,
-                                 driver_listener_writable,
-                                 driver_listener_expired,
-                                 driver_listener_finalize);
-  pni_selectable_set_fd(l->selectable, fd);
+  l->selectable = pn_selectable();
+  pn_selectable_set_reading(l->selectable, true);
+  pn_selectable_set_fd(l->selectable, fd);
   pni_selectable_set_context(l->selectable, l);
   pn_driver_add_listener(driver, l);
   return l;
@@ -244,7 +203,7 @@ pn_listener_t *pn_listener_fd(pn_driver_t *driver, pn_socket_t fd, void
*context
 pn_socket_t pn_listener_get_fd(pn_listener_t *listener)
 {
   assert(listener);
-  return pn_selectable_fd(listener->selectable);
+  return pn_selectable_get_fd(listener->selectable);
 }
 
 pn_listener_t *pn_listener_head(pn_driver_t *driver)
@@ -276,7 +235,7 @@ pn_connector_t *pn_listener_accept(pn_listener_t *l)
   if (!l || !l->pending) return NULL;
   char name[PN_NAME_MAX];
 
-  pn_socket_t sock = pn_accept(l->driver->io, pn_selectable_fd(l->selectable), name,
PN_NAME_MAX);
+  pn_socket_t sock = pn_accept(l->driver->io, pn_selectable_get_fd(l->selectable),
name, PN_NAME_MAX);
   if (sock == PN_INVALID_SOCKET) {
     return NULL;
   } else {
@@ -297,7 +256,7 @@ void pn_listener_close(pn_listener_t *l)
   if (!l) return;
   if (l->closed) return;
 
-  pn_close(l->driver->io, pn_selectable_fd(l->selectable));
+  pn_close(l->driver->io, pn_selectable_get_fd(l->selectable));
   l->closed = true;
 }
 
@@ -312,44 +271,6 @@ void pn_listener_free(pn_listener_t *l)
 
 // connector
 
-static ssize_t driver_connection_capacity(pn_selectable_t *sel)
-{
-  pn_connector_t *c = (pn_connector_t *) pni_selectable_get_context(sel);
-  return c->posted_status & PN_SEL_RD ? 1 : 0;
-}
-
-static ssize_t driver_connection_pending(pn_selectable_t *sel)
-{
-  pn_connector_t *c = (pn_connector_t *) pni_selectable_get_context(sel);
-  return c->posted_status & PN_SEL_WR ? 1 : 0;
-}
-
-static pn_timestamp_t driver_connection_deadline(pn_selectable_t *sel)
-{
-  pn_connector_t *c = (pn_connector_t *) pni_selectable_get_context(sel);
-  return c->posted_wakeup;
-}
-
-static void driver_connection_readable(pn_selectable_t *sel)
-{
-  // do nothing
-}
-
-static void driver_connection_writable(pn_selectable_t *sel)
-{
-  // do nothing
-}
-
-static void driver_connection_expired(pn_selectable_t *sel)
-{
-  // do nothing
-}
-
-static void driver_connection_finalize(pn_selectable_t *sel)
-{
-  // do nothing
-}
-
 static void pn_driver_add_connector(pn_driver_t *d, pn_connector_t *c)
 {
   if (!c->driver) return;
@@ -422,14 +343,8 @@ pn_connector_t *pn_connector_fd(pn_driver_t *driver, pn_socket_t fd,
void *conte
   c->output_done = false;
   c->context = context;
   c->listener = NULL;
-  c->selectable = pni_selectable(driver_connection_capacity,
-                                 driver_connection_pending,
-                                 driver_connection_deadline,
-                                 driver_connection_readable,
-                                 driver_connection_writable,
-                                 driver_connection_expired,
-                                 driver_connection_finalize);
-  pni_selectable_set_fd(c->selectable, fd);
+  c->selectable = pn_selectable();
+  pn_selectable_set_fd(c->selectable, fd);
   pni_selectable_set_context(c->selectable, c);
   pn_connector_trace(c, driver->trace);
 
@@ -440,7 +355,7 @@ pn_connector_t *pn_connector_fd(pn_driver_t *driver, pn_socket_t fd, void
*conte
 pn_socket_t pn_connector_get_fd(pn_connector_t *connector)
 {
   assert(connector);
-  return pn_selectable_fd(connector->selectable);
+  return pn_selectable_get_fd(connector->selectable);
 }
 
 pn_connector_t *pn_connector_head(pn_driver_t *driver)
@@ -518,7 +433,7 @@ void pn_connector_close(pn_connector_t *ctor)
   if (!ctor) return;
 
   ctor->status = 0;
-  pn_close(ctor->driver->io, pn_selectable_fd(ctor->selectable));
+  pn_close(ctor->driver->io, pn_selectable_get_fd(ctor->selectable));
   ctor->closed = true;
 }
 
@@ -587,7 +502,7 @@ void pn_connector_process(pn_connector_t *c)
     if (c->closed) return;
 
     pn_transport_t *transport = c->transport;
-    pn_socket_t sock = pn_selectable_fd(c->selectable);
+    pn_socket_t sock = pn_selectable_get_fd(c->selectable);
 
     ///
     /// Socket read
@@ -782,6 +697,10 @@ int pn_driver_wait_2(pn_driver_t *d, int timeout)
     if (c->posted_status != current_status || c->posted_wakeup != current_wakeup) {
       c->posted_status = current_status;
       c->posted_wakeup = current_wakeup;
+      pn_selectable_t *sel = c->selectable;
+      pn_selectable_set_reading(sel, c->posted_status & PN_SEL_RD ? 1 : 0);
+      pn_selectable_set_writing(sel, c->posted_status & PN_SEL_WR ? 1 : 0);
+      pn_selectable_set_deadline(sel, c->posted_wakeup);
       pn_selector_update(c->driver->selector, c->selectable);
     }
     if (c->closed) {
@@ -789,6 +708,7 @@ int pn_driver_wait_2(pn_driver_t *d, int timeout)
       c->pending_write = false;
       c->pending_tick = false;
       LL_ADD(d, ready_connector, c);
+      pn_selectable_terminate(c->selectable);
     }
     c = c->connector_next;
   }
@@ -892,13 +812,8 @@ pn_connector_t *pn_driver_connector(pn_driver_t *d) {
 static pn_selectable_t *create_ctrl_selectable(pn_socket_t fd)
 {
   // ctrl input only needs to know about read events, just like a listener.
-  pn_selectable_t *sel = pni_selectable(driver_listener_capacity,
-                                        driver_listener_pending,
-                                        driver_listener_deadline,
-                                        driver_listener_readable,
-                                        driver_listener_writable,
-                                        driver_listener_expired,
-                                        driver_listener_finalize);
-  pni_selectable_set_fd(sel, fd);
+  pn_selectable_t *sel = pn_selectable();
+  pn_selectable_set_reading(sel, true);
+  pn_selectable_set_fd(sel, fd);
   return sel;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/43384c15/proton-c/src/windows/selector.c
----------------------------------------------------------------------
diff --git a/proton-c/src/windows/selector.c b/proton-c/src/windows/selector.c
index dfb57d3..a59dc9c 100644
--- a/proton-c/src/windows/selector.c
+++ b/proton-c/src/windows/selector.c
@@ -48,7 +48,6 @@ struct pn_selector_t {
   size_t capacity;
   pn_list_t *selectables;
   pn_list_t *iocp_descriptors;
-  pn_timestamp_t deadline;
   size_t current;
   iocpdesc_t *current_triggered;
   pn_timestamp_t awoken;
@@ -67,7 +66,6 @@ void pn_selector_initialize(void *obj)
   selector->capacity = 0;
   selector->selectables = pn_list(PN_WEAKREF, 0);
   selector->iocp_descriptors = pn_list(PN_OBJECT, 0);
-  selector->deadline = 0;
   selector->current = 0;
   selector->current_triggered = NULL;
   selector->awoken = 0;
@@ -149,17 +147,17 @@ void pn_selector_update(pn_selector_t *selector, pn_selectable_t *selectable)
 {
   int idx = pni_selectable_get_index(selectable);
   assert(idx >= 0);
-  selector->deadlines[idx] = pn_selectable_deadline(selectable);
+  selector->deadlines[idx] = pn_selectable_get_deadline(selectable);
 
   pn_socket_t sock = pn_selectable_get_fd(selectable);
   iocpdesc_t *iocpd = (iocpdesc_t *) pn_list_get(selector->iocp_descriptors, idx);
   if (iocpd) {
     assert(sock == iocpd->socket || iocpd->closing);
     int interests = 0;
-    if (pn_selectable_capacity(selectable) > 0) {
+    if (pn_selectable_is_reading(selectable)) {
       interests |= PN_READABLE;
     }
-    if (pn_selectable_pending(selectable) > 0) {
+    if (pn_selectable_is_writing(selectable)) {
       interests |= PN_WRITABLE;
     }
     if (selector->deadlines[idx]) {
@@ -220,15 +218,15 @@ int pn_selector_select(pn_selector_t *selector, int timeout)
       deadline = selector->deadlines_head->deadline;
   }
   if (deadline) {
-    int delta = deadline - now;
+    int64_t delta = deadline - now;
     if (delta < 0) {
       delta = 0;
-    } 
+    }
     if (timeout < 0)
       timeout = delta;
     else if (timeout > delta)
       timeout = delta;
-  }	
+  }
   deadline = (timeout >= 0) ? now + timeout : 0;
 
   // Process all currently available completions, even if matched events available


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message