| 909 | } |
| 910 | |
| 911 | static int |
| 912 | synserver_vc_accept(TSCont contp, TSEvent event, void *data) |
| 913 | { |
| 914 | TSAssert((event == TS_EVENT_NET_ACCEPT) || (event == TS_EVENT_NET_ACCEPT_FAILED)); |
| 915 | |
| 916 | SocketServer *s = static_cast<SocketServer *>(TSContDataGet(contp)); |
| 917 | TSAssert(s->magic == MAGIC_ALIVE); |
| 918 | |
| 919 | if (event == TS_EVENT_NET_ACCEPT_FAILED) { |
| 920 | if (s && s->accept_port != SYNSERVER_DUMMY_PORT) { |
| 921 | Warning("Synserver failed to bind to port %d.", ntohs(s->accept_port)); |
| 922 | ink_release_assert(!"Synserver must be able to bind to a port, check system netstat"); |
| 923 | Dbg(dbg_ctl_SockServer, "%s: NET_ACCEPT_FAILED", __func__); |
| 924 | } |
| 925 | return TS_EVENT_IMMEDIATE; |
| 926 | } |
| 927 | |
| 928 | Dbg(dbg_ctl_SockServer, "%s: NET_ACCEPT", __func__); |
| 929 | |
| 930 | /* Create a new transaction */ |
| 931 | ServerTxn *txn = static_cast<ServerTxn *>(TSmalloc(sizeof(ServerTxn))); |
| 932 | txn->magic = MAGIC_ALIVE; |
| 933 | |
| 934 | SET_TEST_HANDLER(txn->current_handler, synserver_txn_read_request_handler); |
| 935 | |
| 936 | TSCont txn_cont = TSContCreate(synserver_txn_main_handler, TSMutexCreate()); |
| 937 | TSContDataSet(txn_cont, txn); |
| 938 | |
| 939 | txn->req_buffer = TSIOBufferCreate(); |
| 940 | txn->req_reader = TSIOBufferReaderAlloc(txn->req_buffer); |
| 941 | |
| 942 | txn->resp_buffer = TSIOBufferCreate(); |
| 943 | txn->resp_reader = TSIOBufferReaderAlloc(txn->resp_buffer); |
| 944 | |
| 945 | txn->request[0] = '\0'; |
| 946 | txn->request_len = 0; |
| 947 | |
| 948 | txn->vconn = static_cast<TSVConn>(data); |
| 949 | |
| 950 | txn->write_vio = nullptr; |
| 951 | |
| 952 | /* start reading */ |
| 953 | txn->read_vio = TSVConnRead(txn->vconn, txn_cont, txn->req_buffer, INT64_MAX); |
| 954 | |
| 955 | return TS_EVENT_IMMEDIATE; |
| 956 | } |
| 957 | |
| 958 | static int |
| 959 | synserver_txn_close(TSCont contp) |
nothing calls this directly
no test coverage detected