ext/iodine/fio.c
/**
 * `fio_force_close` closes the connection immediately, without adhering to any
 * protocol restrictions and without sending any remaining data in the
 * connection buffer.
 */
`fio_force_close` closes the connection immediately, without adhering to any
protocol restrictions and without sending any remaining data in the
connection buffer.
` fio_force_close ` closes the connection immediately without adhering to any protocol restrictions and without sending any remaining data in the connection buffer .
void fio_force_close(intptr_t uuid) {
  if (!uuid_is_valid(uuid)) {
    errno = EBADF;
    return;
  }
  if (!uuid_data(uuid).close)
    uuid_data(uuid).close = 1;
  fio_packet_s *packet = NULL;
  fio_lock(&uuid_data(uuid).sock_lock);
  packet = uuid_data(uuid).packet;
  uuid_data(uuid).packet = NULL;
  uuid_data(uuid).packet_last = &uuid_data(uuid).packet;
  uuid_data(uuid).sent = 0;
  fio_unlock(&uuid_data(uuid).sock_lock);
  while (packet) {
    fio_packet_s *tmp = packet;
    packet = packet->next;
    fio_packet_free(tmp);
  }
  if (uuid_data(uuid).open && (uuid_data(uuid).close & 1) &&
      uuid_data(uuid).rw_hooks->before_close(uuid, uuid_data(uuid).rw_udata)) {
    uuid_data(uuid).close = 2; 
    fio_touch(uuid);
    fio_poll_add_write(fio_uuid2fd(uuid));
    return;
  }
  fio_lock(&uuid_data(uuid).protocol_lock);
  fio_clear_fd(fio_uuid2fd(uuid), 0);
  fio_unlock(&uuid_data(uuid).protocol_lock);
  close(fio_uuid2fd(uuid));
#if FIO_ENGINE_POLL
  fio_poll_remove_fd(fio_uuid2fd(uuid));
#endif
  if (fio_data->connection_count)
    fio_atomic_sub(&fio_data->connection_count, 1);
}
void fio_force_close ( intptr_t uuid ) { if ( ! uuid_is_valid ( uuid ) ) { errno = EBADF ; return ; } if ( ! uuid_data ( uuid ) . close ) uuid_data ( uuid ) . close = 1 ; fio_packet_s * packet = NULL ; fio_lock ( & uuid_data ( uuid ) . sock_lock ) ; packet = uuid_data ( uuid ) . packet ; uuid_data ( uuid ) . packet = NULL ; uuid_data ( uuid ) . packet_last = & uuid_data ( uuid ) . packet ; uuid_data ( uuid ) . sent = 0 ; fio_unlock ( & uuid_data ( uuid ) . sock_lock ) ; while ( packet ) { fio_packet_s * tmp = packet ; packet = packet -> next ; fio_packet_free ( tmp ) ; } if ( uuid_data ( uuid ) . open && ( uuid_data ( uuid ) . close & 1 ) && uuid_data ( uuid ) . rw_hooks -> before_close ( uuid , uuid_data ( uuid ) . rw_udata ) ) { uuid_data ( uuid ) . close = 2 ; fio_touch ( uuid ) ; fio_poll_add_write ( fio_uuid2fd ( uuid ) ) ; return ; } fio_lock ( & uuid_data ( uuid ) . protocol_lock ) ; fio_clear_fd ( fio_uuid2fd ( uuid ) , 0 ) ; fio_unlock ( & uuid_data ( uuid ) . protocol_lock ) ; close ( fio_uuid2fd ( uuid ) ) ; #if FIO_ENGINE_POLL fio_poll_remove_fd ( fio_uuid2fd ( uuid ) ) ; #endif if ( fio_data -> connection_count ) fio_atomic_sub ( & fio_data -> connection_count , 1 ) ; }
`fio_force_close` closes the connection immediately, without adhering to any
 protocol restrictions and without sending any remaining data in the
 connection buffer.
` fio_force_close ` closes the connection immediately without adhering to any protocol restrictions and without sending any remaining data in the connection buffer .
// FIO_LOG_DEBUG("fio_force_close called for uuid %p", (void *)uuid); /* make sure the close marker is set */ /* clear away any packets in case we want to cut the connection short. */ /* check for rw-hooks termination packet */ /* don't repeat the before_close callback */