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

TPORT_DLL int tport_shutdown ( tport_t *  self,
int  how 
)

Shutdown a transport connection.

Shutdown a transport.

The tport_shutdown() shuts down a full-duplex transport connection partially or completely. If how is 0, the further incoming data is shut down. If how is 1, further outgoing data is shut down. If how is 2, both incoming and outgoing traffic is shut down.

Definition at line 2007 of file tport.c.

References msg_ref_destroy(), SU_DEBUG_7, tport_is_secondary(), tport_is_tcp(), and tport_shutdown().

Referenced by server_reply(), tport_hup_event(), tport_recv_event(), tport_send_msg(), and tport_shutdown().

{
  if (!tport_is_secondary(self))
    return -1;
  
  SU_DEBUG_7(("%s(%p, %d)\n", "tport_shutdown", (void *)self, how));

  if (!tport_is_tcp(self) ||
      how < 0 || 
      (how == 0 && self->tp_send_close) ||
      (how == 1 && self->tp_recv_close > 1) || 
      how >= 2) {
    tport_close(self);
    return 1;
  }

  if (self->tp_pri->pri_vtable->vtp_shutdown)
    self->tp_pri->pri_vtable->vtp_shutdown(self, how);
  else
    shutdown(self->tp_socket, how);

  if (how == 0) {
    self->tp_recv_close = 2;
    tport_set_events(self, 0, SU_WAIT_IN);
    if (self->tp_params->tpp_sdwn_error && self->tp_pused)
      tport_error_report(self, -1, NULL);
  }
  else if (how == 1) {
    self->tp_send_close = 2;
    tport_set_events(self, 0, SU_WAIT_OUT);
    if (self->tp_queue && self->tp_queue[self->tp_qhead]) {
      unsigned short i, N = self->tp_params->tpp_qsize;
      for (i = 0; i < N; i++) {
      if (self->tp_queue[i]) {
        tport_pending_errmsg(self, self->tp_queue[i], EPIPE);
        msg_ref_destroy(self->tp_queue[i]), self->tp_queue[i] = NULL;
      }
      }
    }
  }


  return 0;
}


Generated by  Doxygen 1.6.0   Back to index