MCPcopy Create free account
hub / github.com/SNAS/openbmp / ClientThread_cancel

Function ClientThread_cancel

Server/src/client_thread.cpp:30–64  ·  view source on GitHub ↗

* Client thread cancel * @param arg Pointer to ClientThreadInfo struct */

Source from the content-addressed store, hash-verified

28 * @param arg Pointer to ClientThreadInfo struct
29 */
30void ClientThread_cancel(void *arg) {
31 ClientThreadInfo *cInfo = static_cast<ClientThreadInfo *>(arg);
32 Logger *logger = cInfo->log;
33
34 if (not cInfo->closing) {
35 cInfo->closing = true;
36
37 LOG_INFO("Thread terminating due to cancel request.");
38
39 LOG_INFO("Closing client connection to %s:%s", cInfo->client->c_ip, cInfo->client->c_port);
40
41 if (cInfo->client->c_sock) {
42 shutdown(cInfo->client->c_sock, SHUT_RDWR);
43 close(cInfo->client->c_sock);
44 }
45
46 usleep(50000);
47
48 close(cInfo->client->pipe_sock);
49 close(cInfo->bmp_write_end_sock);
50
51 if (cInfo->bmp_reader_thread->joinable())
52 cInfo->bmp_reader_thread->join();
53
54 if (cInfo->bmp_reader_thread != NULL) {
55 delete cInfo->bmp_reader_thread;
56 cInfo->bmp_reader_thread = NULL;
57 }
58
59 if (cInfo->mbus != NULL) {
60 delete cInfo->mbus;
61 cInfo->mbus = NULL;
62 }
63 }
64}
65
66/**
67 * Client thread function

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected