This change to pn_messenger_flow() makes my problem go away. 

I get nicely-interleaved messages from my two senders, 
but I haven't done any other testing. 

However, I don't understand the code very well yet.
Does this look to anyone else like it makes sense ? 




void pn_messenger_flow(pn_messenger_t *messenger)
{
  while (messenger->credit > 0) {
    int prev = messenger->credit;
    pn_connector_t *ctor = pn_connector_head(messenger->driver);
    while (ctor) {
      pn_connection_t *conn = pn_connector_connection(ctor);

      pn_link_t *link = pn_link_head(conn, PN_LOCAL_ACTIVE);

      while (link && messenger->credit > 0) {
        if (pn_link_is_receiver(link)) {
          pn_link_flow(link, 1);
          int incoming = pn_messenger_incoming ( messenger );   <----

          if ( incoming > 0 )                                   <----
          {
            messenger->credit -= incoming;                      <----
            if ( messenger->credit < 0 )                        <----
              messenger->credit = 0;                            <----
            messenger->distributed += incoming;                 <----
          }
        }
        link = pn_link_next(link, PN_LOCAL_ACTIVE);
      }

      ctor = pn_connector_next(ctor);
    }
    if (messenger->credit == prev) break;
  }
}

Reply via email to