MCPcopy Create free account
hub / github.com/SIPp/sipp / invalidate

Method invalidate

src/socket.cpp:917–1007  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

915}
916
917void SIPpSocket::invalidate()
918{
919 unsigned pollidx;
920
921 if (ss_invalid) {
922 return;
923 }
924
925#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
926 if (SSL *ssl = ss_ssl) {
927 SSL_set_shutdown(ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
928 SSL_free(ssl);
929 }
930#endif
931
932 /* In some error conditions, the socket FD has already been closed - if it hasn't, do so now. */
933 if (ss_fd != -1) {
934#ifdef HAVE_EPOLL
935 int rc = epoll_ctl(epollfd, EPOLL_CTL_DEL, ss_fd, nullptr);
936 if (rc == -1) {
937 WARNING_NO("Failed to delete FD from epoll");
938 }
939#endif
940 }
941 if (ss_fd != -1 && ss_fd != stdin_fileno) {
942 if (ss_transport == T_TCP && ss_transport != T_TLS) {
943 if (shutdown(ss_fd, SHUT_RDWR) < 0) {
944 WARNING_NO("Failed to shutdown socket %d", ss_fd);
945 }
946 }
947
948#ifdef USE_SCTP
949 if (ss_transport == T_SCTP && !gracefulclose) {
950 struct linger ling = {1, 0};
951 if (setsockopt(ss_fd, SOL_SOCKET, SO_LINGER, &ling, sizeof(ling)) < 0) {
952 WARNING("Unable to set SO_LINGER option for SCTP close");
953 }
954 }
955#endif
956
957 if (::close(ss_fd) < 0) {
958 WARNING_NO("Failed to close socket %d", ss_fd);
959 }
960 }
961
962 if ((pollidx = ss_pollidx) >= pollnfds) {
963 ERROR("Pollset error: index %d is greater than number of fds %d!", pollidx, pollnfds);
964 }
965
966 ss_fd = -1;
967 ss_invalid = true;
968 ss_pollidx = -1;
969
970 /* Adds call sockets in the array */
971 assert(pollnfds > 0);
972
973 pollnfds--;
974#ifdef HAVE_EPOLL

Callers

nothing calls this directly

Calls 3

WARNING_NOFunction · 0.85
WARNINGFunction · 0.85
ERRORFunction · 0.85

Tested by

no test coverage detected