void ppp_remark_mem_free(void) { // int i = 0; ppp_if_mem_free(); if(multilink_if_list != NULL) { list_delete(multilink_if_list); multilink_if_list = NULL; } if(remote_userinfo_list != NULL) { list_delete(remote_userinfo_list); remote_userinfo_list = NULL; } if(g_ppp_mcp_sock->ibuf != NULL) stream_free(g_ppp_mcp_sock->ibuf); if(g_ppp_mcp_sock->obuf != NULL) stream_fifo_free(g_ppp_mcp_sock->obuf); if(g_ppp_mcp_sock->fd > 0) close(g_ppp_mcp_sock->fd); if(g_ppp_mcp_sock != NULL) free(g_ppp_mcp_sock); return; }
/* release all mem associated with a peer */ static void pim_msdp_peer_free(struct pim_msdp_peer *mp) { /* * Let's make sure we are not running when we delete * the underlying data structure */ pim_msdp_peer_stop_tcp_conn(mp, false); if (mp->ibuf) { stream_free(mp->ibuf); } if (mp->obuf) { stream_fifo_free(mp->obuf); } if (mp->mesh_group_name) { XFREE(MTYPE_PIM_MSDP_MG_NAME, mp->mesh_group_name); } mp->pim = NULL; XFREE(MTYPE_PIM_MSDP_PEER, mp); }
/******************************************************************************* Func Name: rcp_session_del Purpose: 根据传入的会话id将会话从会话表中删除 Input: sessiontable,全局会话表 id,要删除的会话id Output: 无 Return: ERR_SUCCESS,删除成功 ERR_FAIL,其他错误 Notes: -------------------------------------------------------------------------------- Development history: Date Author ChangeId Description 2009-2-4 xujian 创建新函数 *******************************************************************************/ s32 rcp_session_del (rcp_session_s **sessiontable, u32 id) { void *arg = NULL; rcp_session_s *sessiondel; s8 *clientipstr; struct in_addr clientip; if (NULL == sessiontable) { return ERROR_FAIL; } if (id > (u32)rcp_max_session_number) { return ERROR_FAIL; } if (NULL == sessiontable[id-1]) { return ERROR_SUCCESS; } sessiondel = sessiontable[id-1]; /*调用thread_cancel删除该会话的t_read*/ THREAD_OFF (sessiondel->t_read); /*如果session->querystate为TRUE*/ if (TRUE == sessiondel->querystate) { /*调用THREAD_ARG从session->t_write中取出arg字段赋给arg*/ arg = THREAD_ARG (sessiondel->t_write); free (arg); } /*调用thread_cancel删除该会话的t_write*/ THREAD_OFF (sessiondel->t_write); /*释放会话的资源并将会话信息表中该会话删除,将会话表中该id置空*/ if (NULL != sessiondel->ibuf) { stream_free (sessiondel->ibuf); sessiondel->ibuf = NULL; } if (NULL != sessiondel->obuf) { stream_fifo_free (sessiondel->obuf); sessiondel->obuf = NULL; } /*关闭会话的socket,判断RCP_DEBUG_EVENTS标志, 如果打开了event debug开关则调用syslogx_send_debug显示删除socket,关闭会话*/ close (sessiondel->fd); clientipstr = inet_ntoa (clientip); if (CHECK_FLAG (g_rcp->debugflag, RCP_DEBUG_EVENTS)) { clientip.s_addr = sessiondel->srcip; clientipstr = inet_ntoa (clientip); syslogex_debug_send("RCP", "Session from client %s has been deleted, and the socket has been closed!", clientipstr); } free (sessiondel); sessiontable[id-1] = NULL; g_rcp->sessionnumber--; return ERROR_SUCCESS; }