Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

int forwarder_empty ( proxy_t pr,
su_wait_t w,
forwarder_t f 
) [static]

Empty forwarder buffers

Definition at line 581 of file su_proxy.c.

References forwarder_close(), forwarder_recv(), SU_DEBUG_1, su_errno, su_free(), su_root_register(), su_root_unregister(), su_strerror(), and su_wait_events().

Referenced by forwarder_recv().

{
  buffer_t *b;
  int n, events;

  events = su_wait_events(w, f->f_socket);

  while ((b = f->f_buf)) {
    n = forwarder_send(f->f_pr, f, b);
    if (n == 0) {
      if ((f->f_buf = b->b_next))
      b->b_next->b_prev = &f->f_buf;
      su_free(f->f_pr->pr_home, b);
      continue;
    }
    else if (n < 0) {
      /* XXX */
    }
    break;
  }

  if (!f->f_buf) {
    forwarder_t *f_peer = f->f_peer;

    su_root_unregister(pr->pr_root, w, forwarder_empty, f);

    if (!f->f_shutdown) {
      /* Buffer is empty - start receiving */
      su_root_register(pr->pr_root, f_peer->f_wait, forwarder_recv, f_peer, 0);
    }
    else {
      if (shutdown(f->f_socket, 1) < 0) {
      SU_DEBUG_1(("shutdown(1): %s\n", su_strerror(su_errno())));
      }
      if (f_peer->f_shutdown) {
      forwarder_close(f);
      }
    }
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index