Lines Matching refs:conn

344     struct ggd_connection *conn)  in exports_check()  argument
362 conn->c_flags |= GGATE_FLAG_RDONLY; in exports_check()
371 conn->c_flags |= GGATE_FLAG_WRONLY; in exports_check()
393 conn->c_flags |= GGATE_FLAG_DIRECT; in exports_check()
402 if ((conn->c_flags & GGATE_FLAG_RDONLY) != 0) in exports_check()
404 else if ((conn->c_flags & GGATE_FLAG_WRONLY) != 0) in exports_check()
409 if (conn->c_diskfd != -1) { in exports_check()
410 if (strcmp(conn->c_path, ex->e_path) != 0) { in exports_check()
413 conn->c_path, ex->e_path); in exports_check()
419 conn->c_diskfd = open(ex->e_path, flags); in exports_check()
420 if (conn->c_diskfd == -1) { in exports_check()
431 struct ggd_connection *conn) in exports_find() argument
449 error = exports_check(ex, cinit, conn); in exports_find()
469 struct ggd_connection *conn, *tconn; in connection_cleanups() local
473 LIST_FOREACH_SAFE(conn, &connections, c_next, tconn) { in connection_cleanups()
474 if (now - conn->c_birthtime > 10) { in connection_cleanups()
475 LIST_REMOVE(conn, c_next); in connection_cleanups()
478 ip2str(conn->c_srcip), conn->c_path); in connection_cleanups()
479 close(conn->c_diskfd); in connection_cleanups()
480 close(conn->c_sendfd); in connection_cleanups()
481 close(conn->c_recvfd); in connection_cleanups()
482 free(conn->c_path); in connection_cleanups()
483 free(conn); in connection_cleanups()
491 struct ggd_connection *conn; in connection_find() local
493 LIST_FOREACH(conn, &connections, c_next) { in connection_find()
494 if (conn->c_token == cinit->gc_token) in connection_find()
497 return (conn); in connection_find()
503 struct ggd_connection *conn; in connection_new() local
514 conn = malloc(sizeof(*conn)); in connection_new()
515 if (conn == NULL) in connection_new()
517 conn->c_path = strdup(cinit->gc_path); in connection_new()
518 if (conn->c_path == NULL) { in connection_new()
519 free(conn); in connection_new()
522 conn->c_token = cinit->gc_token; in connection_new()
524 conn->c_srcip = ip; in connection_new()
525 conn->c_diskfd = conn->c_sendfd = conn->c_recvfd = -1; in connection_new()
527 conn->c_sendfd = sfd; in connection_new()
529 conn->c_recvfd = sfd; in connection_new()
530 conn->c_mediasize = 0; in connection_new()
531 conn->c_sectorsize = 0; in connection_new()
532 time(&conn->c_birthtime); in connection_new()
533 conn->c_flags = cinit->gc_flags; in connection_new()
534 LIST_INSERT_HEAD(&connections, conn, c_next); in connection_new()
536 conn->c_path); in connection_new()
537 return (conn); in connection_new()
541 connection_add(struct ggd_connection *conn, struct g_gate_cinit *cinit, in connection_add() argument
548 if (conn->c_sendfd != -1) { in connection_add()
551 conn->c_path); in connection_add()
554 conn->c_sendfd = sfd; in connection_add()
556 if (conn->c_recvfd != -1) { in connection_add()
559 ip2str(ip), conn->c_path); in connection_add()
562 conn->c_recvfd = sfd; in connection_add()
565 conn->c_path); in connection_add()
574 connection_remove(struct ggd_connection *conn) in connection_remove() argument
577 LIST_REMOVE(conn, c_next); in connection_remove()
579 ip2str(conn->c_srcip), conn->c_path); in connection_remove()
580 if (conn->c_diskfd != -1) in connection_remove()
581 close(conn->c_diskfd); in connection_remove()
582 if (conn->c_sendfd != -1) in connection_remove()
583 close(conn->c_sendfd); in connection_remove()
584 if (conn->c_recvfd != -1) in connection_remove()
585 close(conn->c_recvfd); in connection_remove()
586 free(conn->c_path); in connection_remove()
587 free(conn); in connection_remove()
591 connection_ready(struct ggd_connection *conn) in connection_ready() argument
594 return (conn->c_sendfd != -1 && conn->c_recvfd != -1); in connection_ready()
598 connection_launch(struct ggd_connection *conn) in connection_launch() argument
610 g_gate_log(LOG_DEBUG, "Process created [%s].", conn->c_path); in connection_launch()
643 error = pthread_create(&td, NULL, send_thread, conn); in connection_launch()
648 error = pthread_create(&td, NULL, recv_thread, conn); in connection_launch()
653 disk_thread(conn); in connection_launch()
695 struct ggd_connection *conn; in recv_thread() local
700 conn = arg; in recv_thread()
701 g_gate_log(LOG_NOTICE, "%s: started [%s]!", __func__, conn->c_path); in recv_thread()
702 fd = conn->c_recvfd; in recv_thread()
760 struct ggd_connection *conn; in disk_thread() local
765 conn = arg; in disk_thread()
766 g_gate_log(LOG_NOTICE, "%s: started [%s]!", __func__, conn->c_path); in disk_thread()
767 fd = conn->c_diskfd; in disk_thread()
785 assert(req->r_offset + req->r_length <= (uintmax_t)conn->c_mediasize); in disk_thread()
786 assert((req->r_offset % conn->c_sectorsize) == 0); in disk_thread()
787 assert((req->r_length % conn->c_sectorsize) == 0); in disk_thread()
853 struct ggd_connection *conn; in send_thread() local
858 conn = arg; in send_thread()
859 g_gate_log(LOG_NOTICE, "%s: started [%s]!", __func__, conn->c_path); in send_thread()
860 fd = conn->c_sendfd; in send_thread()
922 struct ggd_connection *conn; in handshake() local
968 conn = connection_find(&cinit); in handshake()
969 if (conn != NULL) { in handshake()
974 (unsigned long)conn->c_token); in handshake()
975 if (connection_add(conn, &cinit, from, sfd) == -1) { in handshake()
976 connection_remove(conn); in handshake()
983 conn = connection_new(&cinit, from, sfd); in handshake()
984 if (conn == NULL) { in handshake()
990 (unsigned long)conn->c_token); in handshake()
993 ex = exports_find(from, &cinit, conn); in handshake()
996 connection_remove(conn); in handshake()
999 if (conn->c_mediasize == 0) { in handshake()
1000 conn->c_mediasize = g_gate_mediasize(conn->c_diskfd); in handshake()
1001 conn->c_sectorsize = g_gate_sectorsize(conn->c_diskfd); in handshake()
1003 sinit.gs_mediasize = conn->c_mediasize; in handshake()
1004 sinit.gs_sectorsize = conn->c_sectorsize; in handshake()
1018 if (connection_ready(conn)) { in handshake()
1019 connection_launch(conn); in handshake()
1020 connection_remove(conn); in handshake()