static StreamClient * find_client(char * s, Channel * c) { unsigned id = 0; if (str2id(s, &id)) { unsigned h = get_client_hash(id, c); LINK * l = handle_hash[h].next; while (l != &handle_hash[h]) { StreamClient * client = hash2client(l); if (client->stream->id == id && client->channel == c) return client; l = l->next; } } errno = ERR_INV_CONTEXT; return NULL; }
static StreamClient * find_client(char * s, Channel * c) { unsigned id = 0; if (str2id(s, &id)) { unsigned h = get_client_hash(id, c); LINK * l = handle_hash[h].next; while (l != &handle_hash[h]) { StreamClient * client = hash2client(l); if (client->stream->id == id && client->channel == c) return client; l = l->next; } } errno = set_fmt_errno(ERR_OTHER, "No such stream: %s", s); return NULL; }
static StreamClient * create_client(VirtualStream * stream, Channel * channel) { StreamClient * client = loc_alloc_zero(sizeof(StreamClient)); list_init(&client->link_hash); list_init(&client->link_stream); list_init(&client->link_all); list_init(&client->read_requests); list_init(&client->write_requests); client->stream = stream; client->channel = channel; list_add_first(&client->link_hash, &handle_hash[get_client_hash(stream->id, channel)]); list_add_first(&client->link_stream, &stream->clients); list_add_first(&client->link_all, &clients); stream->ref_cnt++; return client; }
static StreamClient * create_client(VirtualStream * stream, Channel * channel) { size_t len = (stream->buf_inp + stream->buf_len - stream->buf_out) % stream->buf_len; StreamClient * client = (StreamClient *)loc_alloc_zero(sizeof(StreamClient)); list_init(&client->link_hash); list_init(&client->link_stream); list_init(&client->link_all); list_init(&client->read_requests); list_init(&client->write_requests); client->stream = stream; client->channel = channel; client->pos = stream->pos - len; list_add_first(&client->link_hash, &handle_hash[get_client_hash(stream->id, channel)]); list_add_first(&client->link_stream, &stream->clients); list_add_first(&client->link_all, &clients); stream->ref_cnt++; return client; }