summaryrefslogtreecommitdiff
path: root/src/ivy.c
diff options
context:
space:
mode:
authorfcolin2005-05-20 15:29:54 +0000
committerfcolin2005-05-20 15:29:54 +0000
commit5a19a3603418ed80bd39fc3a260ff6557045f7b0 (patch)
tree966cc8b2fcd3b81aaaec5d7b28f75b7469f571f0 /src/ivy.c
parente1b08a3c4cd478ed73b78152c9ec5252bcfc395a (diff)
downloadivy-c-5a19a3603418ed80bd39fc3a260ff6557045f7b0.zip
ivy-c-5a19a3603418ed80bd39fc3a260ff6557045f7b0.tar.gz
ivy-c-5a19a3603418ed80bd39fc3a260ff6557045f7b0.tar.bz2
ivy-c-5a19a3603418ed80bd39fc3a260ff6557045f7b0.tar.xz
portages des modifications sur windows
Diffstat (limited to 'src/ivy.c')
-rw-r--r--src/ivy.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/ivy.c b/src/ivy.c
index 21e1841..ec1fc53 100644
--- a/src/ivy.c
+++ b/src/ivy.c
@@ -17,7 +17,10 @@
*/
#include <stdlib.h>
+#ifdef WIN32
+#else
#include <arpa/inet.h>
+#endif
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
@@ -186,6 +189,9 @@ static void IvyCleanup()
static int
MsgCall (const char *message, MsgSndPtr msg, Client client)
{
+ static char *buffer = NULL; /* Use satic mem to eliminate multiple call to malloc /free */
+ static int size = 0; /* donc non reentrant !!!! */
+ int offset = 0;
int ovector[OVECSIZE];
int index;
int rc=pcre_exec(
@@ -204,19 +210,18 @@ MsgCall (const char *message, MsgSndPtr msg, Client client)
// il faut essayer d'envoyer le message en une seule fois sur la socket
// pour eviter au maximun de passer dans le select plusieur fois par message du protocole Ivy
// pour eviter la latence ( PB de perfo detecte par ivyperf ping roudtrip )
- SocketSendBuffered( client, "%d %d" ARG_START ,Msg, msg->id);
+ offset += make_message_var( &buffer, &size, offset, "%d %d" ARG_START ,Msg, msg->id);
#ifdef DEBUG
printf( "Send matching args count %ld\n",msg->regexp.re_nsub);
#endif
index=1;
while ( index<rc ) {
- SocketSendBuffered( client, "%.*s" ARG_END , ovector[2*index+1]- ovector[2*index],
+ offset += make_message_var( &buffer, &size, offset, "%.*s" ARG_END , ovector[2*index+1]- ovector[2*index],
message + ovector[2*index]);
++index;
}
-
- SocketSendBuffered (client, "\n");
- SocketFlush( client );
+ offset += make_message_var( &buffer, &size, offset, "\n");
+ SocketSendRaw(client, buffer , offset);
return 1;
}
@@ -836,7 +841,7 @@ IvyBindMsg (MsgCallback callback, void *user_data, const char *fmt_regex, ... )
MsgRcvPtr msg;
va_start (ap, fmt_regex );
- make_message( &buffer, &size, fmt_regex, ap );
+ make_message( &buffer, &size, 0, fmt_regex, ap );
va_end (ap );
/* add Msg to the query list */
@@ -864,7 +869,7 @@ int IvySendMsg(const char *fmt, ...)
va_list ap;
va_start( ap, fmt );
- make_message( &buffer, &size, fmt, ap );
+ make_message( &buffer, &size, 0, fmt, ap );
va_end ( ap );
/* recherche dans la liste des requetes recues de mes clients */
@@ -884,7 +889,7 @@ void IvySendError( IvyClientPtr app, int id, const char *fmt, ... )
va_list ap;
va_start( ap, fmt );
- make_message( &buffer, &size, fmt, ap );
+ make_message( &buffer, &size, 0, fmt, ap );
va_end ( ap );
MsgSendTo( app->client, Error, id, buffer);
}