Lines Matching refs:nc
248 struct cl_conn *nc; /* Server network connection */
946 static int net_get_header(struct cl_conn *nc, struct blktrace_net_hdr *bnh)
949 int fl = fcntl(nc->fd, F_GETFL);
951 fcntl(nc->fd, F_SETFL, fl | O_NONBLOCK);
952 bytes_read = __net_recv_data(nc->fd, bnh, sizeof(*bnh));
953 fcntl(nc->fd, F_SETFL, fl & ~O_NONBLOCK);
1574 struct cl_conn *nc = iop->nc;
1578 nc->ch->hostname);
2270 struct cl_conn *nc;
2272 nc = malloc(sizeof(*nc));
2273 memset(nc, 0, sizeof(*nc));
2275 time(&nc->connect_time);
2276 nc->ch = ch;
2277 nc->fd = fd;
2278 nc->ncpus = -1;
2280 list_add_tail(&nc->ch_head, &ch->conn_list);
2283 list_add_tail(&nc->ns_head, &ns->conn_list);
2289 struct cl_conn *nc)
2291 net_close_connection(&nc->fd);
2293 list_del(&nc->ch_head);
2296 list_del(&nc->ns_head);
2300 free(nc);
2363 struct cl_conn *nc = list_entry(p, struct cl_conn, ch_head);
2365 ch_rem_connection(ns, ch, nc);
2398 static struct devpath *nc_add_dpp(struct cl_conn *nc,
2412 dpp->ch = nc->ch;
2415 dpp->ncpus = nc->ncpus;
2419 list_add_tail(&dpp->head, &nc->ch->devpaths);
2420 nc->ch->ndevs++;
2422 dpp->ios = calloc(nc->ncpus, sizeof(*iop));
2425 for (cpu = 0, iop = dpp->ios; cpu < nc->ncpus; cpu++, iop++) {
2427 iop->nc = nc;
2447 static struct devpath *nc_find_dpp(struct cl_conn *nc,
2451 time_t connect_time = nc->connect_time;
2453 __list_for_each(p, &nc->ch->devpaths) {
2463 return nc_add_dpp(nc, bnh, connect_time);
2466 static void net_client_read_data(struct cl_conn *nc, struct devpath *dpp,
2475 nc->ch->hostname, nc->fd);
2479 ret = net_recv_data(nc->fd, mip->fs_buf + mip->fs_off, bnh->len);
2492 static int net_client_data(struct cl_conn *nc)
2498 ret = net_get_header(nc, &bnh);
2503 fprintf(stderr, "ncd(%d): header read failed\n", nc->fd);
2508 fprintf(stderr, "ncd(%d): received data is bad\n", nc->fd);
2525 nc->ch->hostname, nc->fd);
2529 if (nc->ncpus == -1)
2530 nc->ncpus = bnh.max_cpus;
2536 dpp = nc_find_dpp(nc, &bnh);
2541 ack_open_close(nc->fd, dpp->buts_name);
2542 nc->ch->cl_opens++;
2549 ack_open_close(nc->fd, dpp->buts_name);
2550 if (--nc->ch->cl_opens == 0) {
2551 show_stats(&nc->ch->devpaths);
2552 net_ch_remove(nc->ch, nc->ncpus);
2556 net_client_read_data(nc, dpp, &bnh);
2563 struct cl_conn *nc;
2570 nc = list_entry(p, struct cl_conn, ns_head);
2572 if (net_client_data(nc) || --events == 0)
2589 struct cl_conn *nc = list_entry(p, struct cl_conn, ns_head);
2591 pfd->fd = nc->fd;