|
@@ -14,8 +14,8 @@
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
* GNU General Public License for more details.
|
|
*
|
|
*
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
|
- * along with this program; if not, write to the Free Software
|
|
|
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
|
+ * along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -76,7 +76,7 @@ static int open_server_sockets(
|
|
|
|
|
|
|
|
|
|
/** Main loop for the Event Dispatcher process.
|
|
/** Main loop for the Event Dispatcher process.
|
|
- *
|
|
|
|
|
|
+ *
|
|
*/
|
|
*/
|
|
int dispatcher_main_loop(void)
|
|
int dispatcher_main_loop(void)
|
|
{
|
|
{
|
|
@@ -348,7 +348,7 @@ int dispatcher_main_loop(void)
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * opens the server socket, which attends (accepts) the clients, that is:
|
|
|
|
|
|
+ * opens the server socket, which attends (accepts) the clients, that is:
|
|
* params:
|
|
* params:
|
|
* address:
|
|
* address:
|
|
* address to which to listen
|
|
* address to which to listen
|
|
@@ -423,7 +423,7 @@ union helper
|
|
};
|
|
};
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Sends event
|
|
|
|
|
|
+ * Sends event
|
|
*
|
|
*
|
|
* returns
|
|
* returns
|
|
* 0 OK
|
|
* 0 OK
|
|
@@ -570,7 +570,7 @@ static inline int add_new_as(int event_idx, int action_idx, struct as_entry *as)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- /*TODO attention, this is pkg_malloc because only the Event_Dispatcher process
|
|
|
|
|
|
+ /*TODO attention, this is pkg_malloc because only the Event_Dispatcher process
|
|
* has to use it !!*/
|
|
* has to use it !!*/
|
|
if(!(the_as->ev_buffer.s = pkg_malloc(AS_BUF_SIZE))) {
|
|
if(!(the_as->ev_buffer.s = pkg_malloc(AS_BUF_SIZE))) {
|
|
LM_ERR("unable to alloc pkg mem for the event buffer\n");
|
|
LM_ERR("unable to alloc pkg mem for the event buffer\n");
|
|
@@ -769,14 +769,14 @@ again:
|
|
/**
|
|
/**
|
|
* This function processess the Application Server buffer. We do buffered
|
|
* This function processess the Application Server buffer. We do buffered
|
|
* processing because it increases performance quite a bit. Any message
|
|
* processing because it increases performance quite a bit. Any message
|
|
- * sent from the AS comes with the first 2 bytes as an NBO unsigned short int
|
|
|
|
|
|
+ * sent from the AS comes with the first 2 bytes as an NBO unsigned short int
|
|
* which says the length of the following message (header and payload).
|
|
* which says the length of the following message (header and payload).
|
|
* This way, we avoid multiple small reads() to the socket, which (as we know), consumes
|
|
* This way, we avoid multiple small reads() to the socket, which (as we know), consumes
|
|
* far more processor because of the kernel read(2) system call. The drawback
|
|
* far more processor because of the kernel read(2) system call. The drawback
|
|
* is the added complexity of maintaining a buffer, the bytes read, and looking
|
|
* is the added complexity of maintaining a buffer, the bytes read, and looking
|
|
* if there is a complete message already prepared.
|
|
* if there is a complete message already prepared.
|
|
*
|
|
*
|
|
- * Actions are supposed to be small, that's why BUF_SIZE is 2000 bytes length.
|
|
|
|
|
|
+ * Actions are supposed to be small, that's why BUF_SIZE is 2000 bytes length.
|
|
* Most of the actions will be that size or less. That is why the 4 bytes telling the
|
|
* Most of the actions will be that size or less. That is why the 4 bytes telling the
|
|
* length of the Action payload are included in its size. This way you can use a fixed size
|
|
* length of the Action payload are included in its size. This way you can use a fixed size
|
|
* buffer to receive the Actions and not need to be pkb_malloc'ing for each new event.
|
|
* buffer to receive the Actions and not need to be pkb_malloc'ing for each new event.
|
|
@@ -1019,7 +1019,7 @@ static int handle_unc_as_data(int fd)
|
|
return -2;
|
|
return -2;
|
|
}
|
|
}
|
|
unc_as_t[i].flags |= HAS_NAME;
|
|
unc_as_t[i].flags |= HAS_NAME;
|
|
- /* the loop's upper bound,
|
|
|
|
|
|
+ /* the loop's upper bound,
|
|
* if 'i' is in the lower part, then look for an unc_as in the upper part*/
|
|
* if 'i' is in the lower part, then look for an unc_as in the upper part*/
|
|
k = (i >= MAX_UNC_AS_NR ? MAX_UNC_AS_NR : 2 * MAX_UNC_AS_NR);
|
|
k = (i >= MAX_UNC_AS_NR ? MAX_UNC_AS_NR : 2 * MAX_UNC_AS_NR);
|
|
/* the loop's lower bound */
|
|
/* the loop's lower bound */
|
|
@@ -1087,14 +1087,14 @@ try_again2:
|
|
return namelen;
|
|
return namelen;
|
|
}
|
|
}
|
|
|
|
|
|
-/* handle new App Server connect.
|
|
|
|
|
|
+/* handle new App Server connect.
|
|
* params:
|
|
* params:
|
|
* fd:
|
|
* fd:
|
|
* fd on which to accept.
|
|
* fd on which to accept.
|
|
* which:
|
|
* which:
|
|
* if the fd is the event one, which='e', if is action, which='a'
|
|
* if the fd is the event one, which='e', if is action, which='a'
|
|
*
|
|
*
|
|
- * TODO: not very reliable, because if someone connects() to one of the serversockets
|
|
|
|
|
|
+ * TODO: not very reliable, because if someone connects() to one of the serversockets
|
|
* but not to the other one, then synchronization would be lost, and any subsequent connect
|
|
* but not to the other one, then synchronization would be lost, and any subsequent connect
|
|
* attempts would fail (remember, we receive a connect in event[] and wait for a connect in action)
|
|
* attempts would fail (remember, we receive a connect in event[] and wait for a connect in action)
|
|
* the point is, the connects must allways come in pairs, if one comes alone, we lost sync.
|
|
* the point is, the connects must allways come in pairs, if one comes alone, we lost sync.
|