Author: tross
Date: Wed Oct 17 18:59:55 2012
New Revision: 1399392
URL: http://svn.apache.org/viewvc?rev=1399392&view=rev
Log:
PROTON-83 - Added improved driver facility for activating connectors from the
application.
Modified:
qpid/proton/trunk/proton-c/include/proton/driver.h
qpid/proton/trunk/proton-c/include/proton/engine.h
qpid/proton/trunk/proton-c/src/driver.c
qpid/proton/trunk/proton-c/src/engine/engine.c
qpid/proton/trunk/tests/proton_tests/engine.py
Modified: qpid/proton/trunk/proton-c/include/proton/driver.h
URL:
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/driver.h?rev=1399392&r1=1399391&r2=1399392&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/include/proton/driver.h (original)
+++ qpid/proton/trunk/proton-c/include/proton/driver.h Wed Oct 17 18:59:55 2012
@@ -50,6 +50,11 @@ typedef struct pn_driver_t pn_driver_t;
typedef struct pn_listener_t pn_listener_t;
typedef struct pn_connector_t pn_connector_t;
+typedef enum {
+ PN_CONNECTOR_WRITABLE,
+ PN_CONNECTOR_READABLE
+} pn_activate_criteria_t;
+
/** Construct a driver
*
* Call pn_driver_free() to release the driver object.
@@ -337,6 +342,16 @@ bool pn_connector_closed(pn_connector_t
*/
void pn_connector_free(pn_connector_t *connector);
+/** Activate a connector when a criteria is met
+ *
+ * Set a criteria for a connector (i.e. it's transport is writable) that, once
met,
+ * the connector shall be placed in the driver's work queue.
+ *
+ * @param[in] connector The connector object to activate
+ * @param[in] criteria The criteria that must be met prior to activating the
connector
+ */
+void pn_connector_activate(pn_connector_t *connector, pn_activate_criteria_t
criteria);
+
#ifdef __cplusplus
}
Modified: qpid/proton/trunk/proton-c/include/proton/engine.h
URL:
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/engine.h?rev=1399392&r1=1399391&r2=1399392&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/include/proton/engine.h (original)
+++ qpid/proton/trunk/proton-c/include/proton/engine.h Wed Oct 17 18:59:55 2012
@@ -249,8 +249,6 @@ pn_link_t *pn_link_head(pn_connection_t
*/
pn_link_t *pn_link_next(pn_link_t *link, pn_state_t state);
-bool pn_connection_writable(pn_connection_t *connection);
-
void pn_connection_open(pn_connection_t *connection);
void pn_connection_close(pn_connection_t *connection);
void pn_connection_free(pn_connection_t *connection);
Modified: qpid/proton/trunk/proton-c/src/driver.c
URL:
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/driver.c?rev=1399392&r1=1399391&r2=1399392&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/driver.c (original)
+++ qpid/proton/trunk/proton-c/src/driver.c Wed Oct 17 18:59:55 2012
@@ -528,6 +528,21 @@ static void pn_connector_process_output(
}
}
+
+void pn_connector_activate(pn_connector_t *ctor, pn_activate_criteria_t crit)
+{
+ switch (crit) {
+ case PN_CONNECTOR_WRITABLE :
+ ctor->status |= PN_SEL_WR;
+ break;
+
+ case PN_CONNECTOR_READABLE :
+ ctor->status |= PN_SEL_RD;
+ break;
+ }
+}
+
+
static void pn_connector_write(pn_connector_t *ctor)
{
if (ctor->output_size > 0) {
@@ -688,10 +703,8 @@ static void pn_driver_rebuild(pn_driver_
for (int i = 0; i < d->connector_count; i++)
{
if (!c->closed) {
- bool has_writable_links = c->connection ?
pn_connection_writable(c->connection) : false;
d->fds[d->nfds].fd = c->fd;
- d->fds[d->nfds].events = (c->status & PN_SEL_RD ? POLLIN : 0) |
- ((has_writable_links || (c->status & PN_SEL_WR)) ? POLLOUT : 0);
+ d->fds[d->nfds].events = (c->status & PN_SEL_RD ? POLLIN : 0) |
(c->status & PN_SEL_WR ? POLLOUT : 0);
d->fds[d->nfds].revents = 0;
c->idx = d->nfds;
d->nfds++;
Modified: qpid/proton/trunk/proton-c/src/engine/engine.c
URL:
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1399392&r1=1399391&r2=1399392&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/engine/engine.c (original)
+++ qpid/proton/trunk/proton-c/src/engine/engine.c Wed Oct 17 18:59:55 2012
@@ -691,25 +691,6 @@ pn_link_t *pn_link_next(pn_link_t *link,
return NULL;
}
-bool pn_connection_writable(pn_connection_t *conn)
-{
- if (!conn)
- return false;
-
- pn_endpoint_t *endpoint = conn->endpoint_head;
-
- while (endpoint) {
- if (pn_matches(endpoint, SENDER, PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE)) {
- pn_link_t *link = (pn_link_t*) endpoint;
- if ((link->available > 0) && (pn_link_credit(link) > 0))
- return true;
- }
- endpoint = endpoint->endpoint_next;
- }
-
- return false;
-}
-
pn_session_t *pn_session(pn_connection_t *conn)
{
if (!conn) return NULL;
Modified: qpid/proton/trunk/tests/proton_tests/engine.py
URL:
http://svn.apache.org/viewvc/qpid/proton/trunk/tests/proton_tests/engine.py?rev=1399392&r1=1399391&r2=1399392&view=diff
==============================================================================
--- qpid/proton/trunk/tests/proton_tests/engine.py (original)
+++ qpid/proton/trunk/tests/proton_tests/engine.py Wed Oct 17 18:59:55 2012
@@ -572,28 +572,6 @@ class CreditTest(Test):
def teardown(self):
self.cleanup()
- def testOffered1(self):
- credit = self.snd.credit
- assert credit == 0, credit
- assert not self.c1.writable # No credit, no offer
- self.snd.offered(5)
- self.pump()
- assert not self.c1.writable # Offered but no receiver credit
- self.rcv.flow(10)
- self.pump()
- assert self.c1.writable # Offered and receiver credit
-
- def testOffered2(self):
- credit = self.snd.credit
- assert credit == 0, credit
- assert not self.c1.writable # No credit, no offer
- self.rcv.flow(10)
- self.pump()
- assert not self.c1.writable # Receiver credit but no offer
- self.snd.offered(5)
- self.pump()
- assert self.c1.writable # Offered and receiver credit
-
def testCreditSender(self):
credit = self.snd.credit
assert credit == 0, credit
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]