Backport port extraction fixes.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 19 Aug 2010 17:43:26 +0000 (17:43 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 19 Aug 2010 17:43:26 +0000 (17:43 +0000)
org.glite.lb.client/src/dump.c
org.glite.lb.client/src/load.c
org.glite.lb.client/src/notification.c
org.glite.lb.client/src/perftest_jobreg.c
org.glite.lb.client/src/purge.c
org.glite.lb.common/src/lb_perftest.c
org.glite.lb.common/src/param.c
org.glite.lb.logger/src/event_queue.c
org.glite.lb.server/src/notif_match.c
org.glite.lb.server/src/notification.c

index b561aa9..f215f55 100644 (file)
@@ -140,7 +140,7 @@ int main(int argc,char *argv[])
        edg_wll_InitContext(&ctx);
        if ( server )
        {
-               char *p = strchr(server, ':');
+               char *p = strrchr(server, ':');
                if ( p )
                {
                        edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, atoi(p+1));
index ed71a4c..b5b6d42 100644 (file)
@@ -112,7 +112,7 @@ int main(int argc,char *argv[])
        edg_wll_InitContext(&ctx);
        if ( server )
        {
-               char *p = strchr(server, ':');
+               char *p = strrchr(server, ':');
                if ( p )
                {
                        edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, atoi(p+1));
index 017240f..e02ff93 100644 (file)
@@ -81,7 +81,7 @@ static void get_name_and_port(const char *address, char **name, int *port)
        char *n = NULL, *p;
        
        n = strdup(address);
-       p = strchr(n, ':');
+       p = strrchr(n, ':');
        if (p)
        {
                *port = atoi(p+1);
index 3d863a3..344041a 100644 (file)
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
        dprintf(("generating jobids..."));
        {
                char *name=server?server:strdup(PROXY_SERVER);
-               char *p = strchr(name,':');
+               char *p = strrchr(name,':');
                int  port;
 
                if (p)  { *p=0; port = atoi(p+1); }
index 8e93e99..1c81a84 100644 (file)
@@ -315,7 +315,7 @@ static int read_jobIds(const char *file, char ***jobs_out)
                        fprintf(stderr, "Error reading file\n");
                        return 1;
                }
-                nl = strchr(buf,'\n');
+                nl = strrchr(buf,'\n');
                 if (nl) *nl = 0;
                /* TODO: check if it is really jobId, e.g. by edg_wlc_JobIdParse() */
 
index c87f942..1e6532f 100644 (file)
@@ -216,7 +216,7 @@ glite_wll_perftest_init(const char *host,
        {
                char *p;
 
-               p = strchr(host, ':');
+               p = strrchr(host, ':');
                if(p) 
                        *p = 0;
                dest_host = strdup(host);
index cda46b4..20b598d 100644 (file)
@@ -85,7 +85,7 @@ static int extract_port(edg_wll_ContextParam param,int dflt)
 {
        char    *p = NULL,*s = mygetenv(param);
 
-        if (s) p = strchr(s,':');
+        if (s) p = strrchr(s,':');
        return  p ? atoi(p+1) : dflt;
 }
 
@@ -102,7 +102,7 @@ static char *extract_host(edg_wll_ContextParam param,const char *dflt)
        s = mygetenv(param);
        if (!s && !dflt) return NULL;
        s = strdup(s?s:dflt),
-       p = strchr(s,':');
+       p = strrchr(s,':');
        if (p) *p = 0;
        return s;
 }
index fcfcfbc..2028b8f 100644 (file)
@@ -27,7 +27,7 @@ event_queue_create(char *server_name)
   struct event_queue *eq;
   char *p;
 
-  p = strchr(server_name, ':');
+  p = strrchr(server_name, ':');
   
   if(p) 
     *p++ = 0;
index 3180751..61940ce 100644 (file)
@@ -79,7 +79,7 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *stat)
                        free(ju);
 
                        dest = strdup(jobc[1]);
-                       if ( !(aux = strchr(dest, ':')) )
+                       if ( !(aux = strrchr(dest, ':')) )
                        {
                                edg_wll_SetError(ctx, EINVAL, "Can't parse notification destination");
                                free(dest);
index 787fa3c..b40cb6e 100644 (file)
@@ -125,12 +125,13 @@ int edg_wll_NotifNewServer(
        {
                char   *aux;
 
-               if ( !(aux = strchr(address_override, ':')) )
+               if ( !(aux = strrchr(address_override, ':')) )
                {
                        edg_wll_SetError(ctx, EINVAL, "Addres overrirde not in format host:port");
                        goto cleanup;
                }
-               if ( !strncmp(address_override, "0.0.0.0", aux-address_override) )
+               if ( !strncmp(address_override, "0.0.0.0", aux-address_override) ||
+                    !strncmp(address_override, "::", aux-address_override) )
                        trio_asprintf(&addr_s, "%s:%s", ctx->connections->serverConnection->peerName, aux+1);
        }
 
@@ -228,12 +229,13 @@ int edg_wll_NotifBindServer(
        {
                char   *aux;
 
-               if ( !(aux = strchr(address_override, ':')) )
+               if ( !(aux = strrchr(address_override, ':')) )
                {
                        edg_wll_SetError(ctx, EINVAL, "Addres overrirde not in format host:port");
                        goto cleanup;
                }
-               if ( !strncmp(address_override, "0.0.0.0", aux-address_override) )
+               if ( !strncmp(address_override, "0.0.0.0", aux-address_override) ||
+                    !strncmp(address_override, "::", aux-address_override) )
                        trio_asprintf(&addr_s, "%s:%s", ctx->connections->serverConnection->peerName, aux+1);
        }