![]() |
|
|||
0001 /** 0002 * @brief Functions for tracking open connections. 0003 * Contains doubly linked list. 0004 * So we will track all incoming & outgoing connections, right? 0005 * 0006 * @file contrack.c 0007 */ 0008 /* ----------------------------------------------------------------------------- 0009 * Enduro/X Middleware Platform for Distributed Transaction Processing 0010 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0011 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0012 * This software is released under one of the following licenses: 0013 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0014 * See LICENSE file for full text. 0015 * ----------------------------------------------------------------------------- 0016 * AGPL license: 0017 * 0018 * This program is free software; you can redistribute it and/or modify it under 0019 * the terms of the GNU Affero General Public License, version 3 as published 0020 * by the Free Software Foundation; 0021 * 0022 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0023 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0024 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0025 * for more details. 0026 * 0027 * You should have received a copy of the GNU Affero General Public License along 0028 * with this program; if not, write to the Free Software Foundation, Inc., 0029 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0030 * 0031 * ----------------------------------------------------------------------------- 0032 * A commercial use license is available from Mavimax, Ltd 0033 * contact@mavimax.com 0034 * ----------------------------------------------------------------------------- 0035 */ 0036 0037 /*---------------------------Includes-----------------------------------*/ 0038 #include <sys/socket.h> 0039 #include <sys/time.h> 0040 #include <sys/types.h> 0041 #include <arpa/inet.h> 0042 #include <netinet/in.h> 0043 #include <errno.h> 0044 #include <fcntl.h> 0045 #include <netdb.h> 0046 #include <string.h> 0047 #include <unistd.h> 0048 #include <atmi.h> 0049 0050 #include <stdio.h> 0051 #include <stdlib.h> 0052 0053 #include <exnet.h> 0054 #include <ndrstandard.h> 0055 #include <ndebug.h> 0056 0057 #include <utlist.h> 0058 0059 #include "exhash.h" 0060 /*---------------------------Externs------------------------------------*/ 0061 /*---------------------------Macros-------------------------------------*/ 0062 /*---------------------------Enums--------------------------------------*/ 0063 /*---------------------------Typedefs-----------------------------------*/ 0064 /*---------------------------Globals------------------------------------*/ 0065 /* Doubly linked list with connections */ 0066 exnetcon_t *M_netlist = NULL; 0067 /*---------------------------Statics------------------------------------*/ 0068 /*---------------------------Prototypes---------------------------------*/ 0069 0070 /** 0071 * Add connection from linked list 0072 * @param 0073 */ 0074 expublic void exnet_add_con(exnetcon_t *net) 0075 { 0076 /* Add stuff to linked list */ 0077 DL_APPEND(M_netlist, net); 0078 } 0079 0080 /** 0081 * Delete connection from linked list. The node will not be deleted by it self. 0082 * Outside process shall do delete. 0083 * @param 0084 */ 0085 expublic void exnet_del_con(exnetcon_t *net) 0086 { 0087 /* delete stuff from linked list */ 0088 DL_DELETE(M_netlist, net); 0089 } 0090 0091 /** 0092 * Get the head of the linked list. 0093 */ 0094 expublic exnetcon_t * extnet_get_con_head(void) 0095 { 0096 return M_netlist; 0097 } 0098 0099 /** 0100 * Find a disconnected connection object to fill the connection details in 0101 * This assumes that we hold read lock on the object. 0102 * @return NULL (not dicon objs) or some obj 0103 */ 0104 expublic exnetcon_t *exnet_find_free_conn(void) 0105 { 0106 exnetcon_t *net; 0107 0108 DL_FOREACH(M_netlist, net) 0109 { 0110 if (!net->is_connected && !net->is_server) 0111 { 0112 return net; 0113 } 0114 } 0115 0116 return NULL; 0117 } 0118 0119 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |