diff --git a/libs/freetdm/src/include/sangoma_tdm_api.h b/libs/freetdm/src/include/sangoma_tdm_api.h index 1e9c610287..98033bb523 100644 --- a/libs/freetdm/src/include/sangoma_tdm_api.h +++ b/libs/freetdm/src/include/sangoma_tdm_api.h @@ -146,6 +146,18 @@ static sng_fd_t tdmv_api_open_span_chan(int span, int chan) #endif } +void tdmv_api_close_socket(sng_fd_t *sp) +{ + if( *sp != INVALID_HANDLE_VALUE){ +#if defined(__WINDOWS__) + CloseHandle(*sp); +#else + close(*sp); +#endif + *sp = INVALID_HANDLE_VALUE; + } +} + #ifdef __WINDOWS__ static int wanpipe_api_ioctl(sng_fd_t fd, wan_cmd_api_t *api_cmd) { diff --git a/libs/freetdm/src/zap_wanpipe.c b/libs/freetdm/src/zap_wanpipe.c index 7d5c9a8de9..57c1aa7400 100644 --- a/libs/freetdm/src/zap_wanpipe.c +++ b/libs/freetdm/src/zap_wanpipe.c @@ -621,12 +621,6 @@ zap_status_t wanpipe_init(zap_software_interface_t **zint) return ZAP_SUCCESS; } -#if defined(__WINDOWS__) -#define close(handle) CloseHandle(handle) -#endif - -#define zap_wanpipe_socket_close(it) if (it != WP_INVALID_SOCKET) { close(it); it = WP_INVALID_SOCKET;} - zap_status_t wanpipe_destroy(void) { unsigned int i,j; @@ -639,7 +633,7 @@ zap_status_t wanpipe_destroy(void) zap_channel_t *cur_chan = &cur_span->channels[j]; if (zap_test_flag(cur_chan, ZAP_CHANNEL_CONFIGURED)) { zap_log(ZAP_LOG_INFO, "Closing channel %u:%u fd:%d\n", cur_chan->span_id, cur_chan->chan_id, cur_chan->sockfd); - zap_wanpipe_socket_close(cur_chan->sockfd); + tdmv_api_close_socket(cur_chan->sockfd); } } }