From 3bf6d4d8f3281ca4922c3276f03881bfd60b83b6 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Sun, 20 May 2007 04:14:23 +0000 Subject: [PATCH] move wanpipe's close function to the cross platform abstraction. git-svn-id: http://svn.openzap.org/svn/openzap/trunk@42 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/src/include/sangoma_tdm_api.h | 12 ++++++++++++ libs/freetdm/src/zap_wanpipe.c | 8 +------- 2 files changed, 13 insertions(+), 7 deletions(-) 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); } } }