Lines Matching refs:nc

248 	struct cl_conn *nc;	/* Server network connection */
924 static int net_get_header(struct cl_conn *nc, struct blktrace_net_hdr *bnh)
927 int fl = fcntl(nc->fd, F_GETFL);
929 fcntl(nc->fd, F_SETFL, fl | O_NONBLOCK);
930 bytes_read = __net_recv_data(nc->fd, bnh, sizeof(*bnh));
931 fcntl(nc->fd, F_SETFL, fl & ~O_NONBLOCK);
1477 struct cl_conn *nc = iop->nc;
1479 len += sprintf(dst + len, "%s-", nc->ch->hostname);
2168 struct cl_conn *nc;
2170 nc = malloc(sizeof(*nc));
2171 memset(nc, 0, sizeof(*nc));
2173 time(&nc->connect_time);
2174 nc->ch = ch;
2175 nc->fd = fd;
2176 nc->ncpus = -1;
2178 list_add_tail(&nc->ch_head, &ch->conn_list);
2181 list_add_tail(&nc->ns_head, &ns->conn_list);
2187 struct cl_conn *nc)
2189 net_close_connection(&nc->fd);
2191 list_del(&nc->ch_head);
2194 list_del(&nc->ns_head);
2198 free(nc);
2261 struct cl_conn *nc = list_entry(p, struct cl_conn, ch_head);
2263 ch_rem_connection(ns, ch, nc);
2296 static struct devpath *nc_add_dpp(struct cl_conn *nc,
2310 dpp->ch = nc->ch;
2313 dpp->ncpus = nc->ncpus;
2317 list_add_tail(&dpp->head, &nc->ch->devpaths);
2318 nc->ch->ndevs++;
2320 dpp->ios = calloc(nc->ncpus, sizeof(*iop));
2323 for (cpu = 0, iop = dpp->ios; cpu < nc->ncpus; cpu++, iop++) {
2325 iop->nc = nc;
2345 static struct devpath *nc_find_dpp(struct cl_conn *nc,
2349 time_t connect_time = nc->connect_time;
2351 __list_for_each(p, &nc->ch->devpaths) {
2361 return nc_add_dpp(nc, bnh, connect_time);
2364 static void net_client_read_data(struct cl_conn *nc, struct devpath *dpp,
2373 nc->ch->hostname, nc->fd);
2377 ret = net_recv_data(nc->fd, mip->fs_buf + mip->fs_off, bnh->len);
2390 static int net_client_data(struct cl_conn *nc)
2396 ret = net_get_header(nc, &bnh);
2401 fprintf(stderr, "ncd(%d): header read failed\n", nc->fd);
2406 fprintf(stderr, "ncd(%d): received data is bad\n", nc->fd);
2423 nc->ch->hostname, nc->fd);
2427 if (nc->ncpus == -1)
2428 nc->ncpus = bnh.max_cpus;
2434 dpp = nc_find_dpp(nc, &bnh);
2439 ack_open_close(nc->fd, dpp->buts_name);
2440 nc->ch->cl_opens++;
2447 ack_open_close(nc->fd, dpp->buts_name);
2448 if (--nc->ch->cl_opens == 0) {
2449 show_stats(&nc->ch->devpaths);
2450 net_ch_remove(nc->ch, nc->ncpus);
2454 net_client_read_data(nc, dpp, &bnh);
2461 struct cl_conn *nc;
2468 nc = list_entry(p, struct cl_conn, ns_head);
2470 if (net_client_data(nc) || --events == 0)
2487 struct cl_conn *nc = list_entry(p, struct cl_conn, ns_head);
2489 pfd->fd = nc->fd;