this function was brought forward from sxcpu/libxcpu to get the local
address of a session.

the old spclient spc_get_local_address function was changed to
spc_getladdr for the sake of consistency.

Signed-off-by: Abhishek Kulkarni <[EMAIL PROTECTED]>

Index: include/libxcpu.h
===================================================================
--- include/libxcpu.h   (revision 734)
+++ include/libxcpu.h   (working copy)
@@ -154,6 +154,7 @@
 
 Xpnode *xp_session_get_node(Xpsession *);
 char *xp_session_get_id(Xpsession *);
+int xp_session_get_localaddr(Xpsession *s, char *buf, int buflen);
 
 Xpcommand *xp_command_create(Xpnodeset *, Spuser *, Xkey *);
 int xp_command_split_by_arch(Xpcommand *, Xpcommand ***);

Index: libxcpu/session.c
===================================================================
--- libxcpu/session.c   (revision 734)
+++ libxcpu/session.c   (working copy)
@@ -503,6 +503,14 @@
        return s->sid;
 }
 
+int xp_session_get_localaddr(Xpsession *s, char *buf, int buflen)
+{
+       if (s->fs)
+               return spc_getladdr(s->fs, buf, buflen);
+       else
+               return -1;
+}
+
 int
 xp_session_close_stdin(Xpsession *s)
 {

Index: libxcpu/command.c
===================================================================
--- libxcpu/command.c   (revision 734)
+++ libxcpu/command.c   (working copy)
@@ -146,7 +146,7 @@
 {
        int i, n, m, err, envlen;
        int ce, cn, b, e;
-       char buf[256], pk[257], *senv, *ep;
+       char pk[257], *senv, *ep;
  
 
        envlen = (cm->env?strlen(cm->env):0) + 256;
@@ -244,7 +244,7 @@
 {
        int i, j, k, nnodes, port;
        u64 l;
-       char *buf, addr[128];
+       char *buf, laddr[128], addr[256];
        Xpsession **ss;
 
        port = 0;
@@ -259,7 +259,9 @@
 
        nnodes = cm->sessions->len;
        ss = cm->sessions->sessions;
-       snprintf(addr, sizeof(addr), "%s!%d",
spc_get_local_address(ss[0]->fs), port);
+       if (xp_session_get_localaddr(ss[0], laddr, sizeof(laddr)) < 0)
+               goto error;
+       snprintf(addr, sizeof(addr), "%s!%d", laddr, port);
        cm->tcnt = nnodes;
        xp_command_treespawn(cm, addr, NULL, cm->nspawn, nnodes, ss);
 
@@ -338,22 +340,22 @@
 
                cms[n]->tcnt = ns;
                for(i = 0; i < ns; i++) {
-                       ss[i]->wspcfd = spcfd_add(ss[i]->wait, 
xp_command_wait_recv, ss[i]);
+                       ss[i]->wspcfd = spcfd_add(ss[i]->wait, 
xp_command_wait_recv, ss[i],
0);
                        if (!ss[i]->wspcfd)
                                goto error;
 
-                       ss[i]->ispcfd = spcfd_add(ss[i]->in, 
xp_command_stdin_send, ss[i]);
+                       ss[i]->ispcfd = spcfd_add(ss[i]->in, 
xp_command_stdin_send, ss[i],
0);
                        if (!ss[i]->ispcfd)
                                goto error;
 
                        if (cms[n]->stdout_cb) {
-                               ss[i]->ospcfd = spcfd_add(ss[i]->out, 
xp_command_stdout_recv,
ss[i]);
+                               ss[i]->ospcfd = spcfd_add(ss[i]->out, 
xp_command_stdout_recv,
ss[i], 0);
                                if (!ss[i]->ospcfd)
                                        goto error;
                        }
 
                        if (cms[n]->stderr_cb) {
-                               ss[i]->espcfd = spcfd_add(ss[i]->err, 
xp_command_stderr_recv,
ss[i]);
+                               ss[i]->espcfd = spcfd_add(ss[i]->err, 
xp_command_stderr_recv,
ss[i], 0);
                                if (!ss[i]->espcfd)
                                        goto error;
                        }

Reply via email to