summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbustico2008-04-08 14:42:23 +0000
committerbustico2008-04-08 14:42:23 +0000
commit1afbcc6fa34335e77e089ddc5d67d069d3189ea7 (patch)
tree188833731be2a66d8e026c8a8f68115359ba4e81 /src
parent540cd95a769b2b85572bdfae26867bedfaf2fb3d (diff)
downloadivy-c-1afbcc6fa34335e77e089ddc5d67d069d3189ea7.zip
ivy-c-1afbcc6fa34335e77e089ddc5d67d069d3189ea7.tar.gz
ivy-c-1afbcc6fa34335e77e089ddc5d67d069d3189ea7.tar.bz2
ivy-c-1afbcc6fa34335e77e089ddc5d67d069d3189ea7.tar.xz
* fix a bug with the behavior of send system call in non blocking mode
in some rare case * simplify ivythroutput and his fileset
Diffstat (limited to 'src')
-rw-r--r--src/Makefile4
-rw-r--r--src/ivy.c32
-rw-r--r--src/ivysocket.c50
3 files changed, 77 insertions, 9 deletions
diff --git a/src/Makefile b/src/Makefile
index acf17d6..1bbe910 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -127,8 +127,10 @@ TARGETLIBS=libivy.so.$(MAJOR).$(MINOR) libgivy.so.$(MAJOR).$(MINOR) libxtivy.so.
.cpp.o:
$(CPP) $(CFLAGS) $(BUGGY_DEBIAN_OPTION) -c $*.cpp
-all: static-libs commands shared-libs pkgconf libomp tools
+all: static-libs commands shared-libs pkgconf tools
libomp: libivy_omp.a libivy_omp.so.$(MAJOR).$(MINOR)
+omp: libomp
+ @(cd $(TOOLS_DIR) && $(MAKE) omp)
static-libs: libivy.a libgivy.a libxtivy.a libglibivy.a libtclivy.a
# not yet need Modified Glut libglutivy.a
diff --git a/src/ivy.c b/src/ivy.c
index 2db1ab1..fd894fd 100644
--- a/src/ivy.c
+++ b/src/ivy.c
@@ -234,6 +234,9 @@ static SendState MsgSendTo(IvyClientPtr ivyClient,
SendState state =
SocketSend( ivyClient->client, "%d %d" ARG_START "%s\n", msgtype, id, message);
+ // if (msgtype == AddRegexp) {
+ //printf ("DBG> MsgSendTo:: sending addRegexp ID=%d [%s]\n", id, message);
+ //}
if ((application_callback != NULL) && (ivyClient != NULL)) {
switch (state) {
case SendStateChangeToCongestion :
@@ -542,7 +545,6 @@ static void Receive( Client client, void *data, char *line )
TRACE("Regexp id=%d exp='%s'\n", id, arg);
-
if ( !IvyBindingFilter( arg ) )
{
@@ -590,7 +592,6 @@ static void Receive( Client client, void *data, char *line )
case EndRegexp:
TRACE("Regexp End id=%d\n", id);
-
if ( application_callback )
{
(*application_callback)( clnt, application_user_data, IvyApplicationConnected );
@@ -1085,8 +1086,8 @@ int IvySendMsg(const char *fmt, ...) /* version dictionnaire */
/* pour toutes les regexp */
#ifdef OPENMP
+#define TABLEAU_PREALABLE 1 // mode normal, les autres sont pour le debug
//#define TABLEAU_PREALABLE_SEQUENTIEL 1
-#define TABLEAU_PREALABLE 1
//#define SINGLE_NOWAIT 1
//#define SCHEDULE_GUIDED 1
//#define SEQUENTIEL_DEBUG 1
@@ -1526,9 +1527,30 @@ static void addRegexpToDictionary (const char* regexp, IvyClientPtr client)
msgSendDict->clientList = NULL;
- /* HASH_ADD_STR ne fonctionne que si la clef est un tavbleau de char, si c'est un pointeur
+ /* HASH_ADD_STR ne fonctionne que si la clef est un tableau de char, si c'est un pointeur
if faut utiliser HASH_ADD_KEYPTR */
+#ifdef DEBUG
+ {// DEBUG
+ int debugSize=0, nDebugSize=0;
+ MsgSndDictPtr msd;
+ for (msd=messSndByRegexp; msd ; msd=msd->hh.next) {
+ debugSize++;
+ }
+ HASH_ADD_KEYPTR(hh, messSndByRegexp, msgSendDict->regexp_src, strlen (msgSendDict->regexp_src), msgSendDict);
+ for (msd=messSndByRegexp; msd ; msd=msd->hh.next) {
+ nDebugSize++;
+ }
+ if ((nDebugSize-debugSize) != 1) {
+ printf ("DBG> Hash ERROR, adding %s let hashsize to pass from %d to %d\n", regexp, debugSize, nDebugSize);
+ } else {
+ printf ("DBG> adding %s[%d]\n", regexp, nDebugSize);
+ }
+
+ }// END DEBUG
+#else
HASH_ADD_KEYPTR(hh, messSndByRegexp, msgSendDict->regexp_src, strlen (msgSendDict->regexp_src), msgSendDict);
+#endif
+
#ifdef OPENMP
// On ne regenere le cache qu'après recpetion du endregexp, ça permet d'eviter
// de regenerer inutilement le cache à chaqye nouvelle regexp initiale
@@ -1557,7 +1579,7 @@ static void addRegexpToDictionary (const char* regexp, IvyClientPtr client)
static void changeRegexpInDictionary (const char* regexp, IvyClientPtr client)
{
- // printf ("ENTER changeRegexpInDictionary\n");
+ // printf ("DBG> ENTER changeRegexpInDictionary\n");
delRegexpForOneClientFromDictionary (regexp, client);
addRegexpToDictionary (regexp, client);
}
diff --git a/src/ivysocket.c b/src/ivysocket.c
index 74bd15e..6702517 100644
--- a/src/ivysocket.c
+++ b/src/ivysocket.c
@@ -425,8 +425,6 @@ SendState SocketSendRaw (const Client client, const char *buffer, const int len
}
-
-
static SendState BufferizedSocketSendRaw (const Client client, const char *buffer, const int len )
{
ssize_t reallySent;
@@ -444,7 +442,19 @@ static SendState BufferizedSocketSendRaw (const Client client, const char *buffe
if (reallySent == len) {
state = SendOk; // PAS CONGESTIONNEE
} else if (reallySent == -1) {
- state = SendError; // ERREUR
+ if (errno == EWOULDBLOCK) {
+ // Aucun octet n'a été envoyé, mais le send ne rend pas 0
+ // car 0 peut être une longueur passée au send, donc dans ce cas
+ // send renvoie -1 et met errno a EWOULDBLOCK
+ client->ifb = IvyFifoNew ();
+ IvyFifoWrite (client->ifb, buffer, len);
+ // on ajoute un fdset pour que le select appelle une callback pour vider
+ // le buffer quand la socket sera ?? nouveau libre
+ IvyChannelAddWritableEvent (client->channel);
+ state = SendStateChangeToCongestion;
+ } else {
+ state = SendError; // ERREUR
+ }
} else {
// socket congestionnée
// on initialise une fifo pour accumuler les données
@@ -456,6 +466,40 @@ static SendState BufferizedSocketSendRaw (const Client client, const char *buffe
state = SendStateChangeToCongestion;
}
}
+
+#ifdef DEBUG
+ // DBG BEGIN DEBUG
+ /* SendOk, SendStillCongestion, SendStateChangeToCongestion,
+ SendStateChangeToDecongestion, SendStateFifoFull, SendError,
+ SendParamError
+ */
+ {
+ static SendState DBG_state = SendOk;
+ char *litState="";
+ if (state != DBG_state) {
+ switch (state) {
+ case SendOk : litState = "SendOk";
+ break;
+ case SendStillCongestion: litState = "SendStillCongestion";
+ break;
+ case SendStateChangeToCongestion : litState = "SendStateChangeToCongestion";
+ break;
+ case SendStateChangeToDecongestion: litState = "SendStateChangeToDecongestion";
+ break;
+ case SendStateFifoFull: litState = "SendStateFifoFull";
+ break;
+ case SendError: litState = "SendError";
+ break;
+ case SendParamError: litState = "SendParamError";
+ break;
+ }
+ printf ("DBG>> BufferizedSocketSendRaw, state changed tp '%s'\n", litState);
+ DBG_state = state;
+ }
+ }
+ // DBG END DEBUG
+#endif
+
return (state);
}