Commit b86a004b authored by Mike Hibler's avatar Mike Hibler

Make sure exptidx gets properly recorded in the port_registration table.

Previously it was not being filled in and would wind up '0'.  Since it was
part of the primary key along with the service, this basically meant that
only one experiment at a time could successfully use the sync-server; i.e.,
only one could have (0, 'emulab-syncd') as their primary key.
parent 29521a2c
...@@ -161,6 +161,7 @@ typedef struct { ...@@ -161,6 +161,7 @@ typedef struct {
int elab_in_elab; int elab_in_elab;
int singlenet; /* Modifier for elab_in_elab */ int singlenet; /* Modifier for elab_in_elab */
int update_accounts; int update_accounts;
int exptidx;
char nodeid[TBDB_FLEN_NODEID]; char nodeid[TBDB_FLEN_NODEID];
char vnodeid[TBDB_FLEN_NODEID]; char vnodeid[TBDB_FLEN_NODEID];
char pnodeid[TBDB_FLEN_NODEID]; /* XXX */ char pnodeid[TBDB_FLEN_NODEID]; /* XXX */
...@@ -4144,7 +4145,8 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp) ...@@ -4144,7 +4145,8 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
" pt.isremotenode,vt.issubnode,e.keyhash, " " pt.isremotenode,vt.issubnode,e.keyhash, "
" nk.sfshostid,e.eventkey,vt.isplabdslice, " " nk.sfshostid,e.eventkey,vt.isplabdslice, "
" ps.admin, " " ps.admin, "
" e.elab_in_elab,e.elabinelab_singlenet " " e.elab_in_elab,e.elabinelab_singlenet, "
" e.idx "
"from nodes as nv " "from nodes as nv "
"left join nodes as np on " "left join nodes as np on "
" np.node_id=nv.phys_nodeid " " np.node_id=nv.phys_nodeid "
...@@ -4164,7 +4166,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp) ...@@ -4164,7 +4166,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
" nk.node_id=nv.node_id " " nk.node_id=nv.node_id "
"where nv.node_id='%s' and " "where nv.node_id='%s' and "
" (i.IP='%s' and i.role='ctrl') ", " (i.IP='%s' and i.role='ctrl') ",
25, reqp->vnodeid, inet_ntoa(ipaddr)); 26, reqp->vnodeid, inet_ntoa(ipaddr));
} }
else { else {
res = mydb_query("select t.class,t.type,n.node_id,n.jailflag," res = mydb_query("select t.class,t.type,n.node_id,n.jailflag,"
...@@ -4174,7 +4176,8 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp) ...@@ -4174,7 +4176,8 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
" e.sync_server,t.class,t.type, " " e.sync_server,t.class,t.type, "
" t.isremotenode,t.issubnode,e.keyhash, " " t.isremotenode,t.issubnode,e.keyhash, "
" nk.sfshostid,e.eventkey,0, " " nk.sfshostid,e.eventkey,0, "
" 0,e.elab_in_elab,e.elabinelab_singlenet " " 0,e.elab_in_elab,e.elabinelab_singlenet, "
" e.idx "
"from interfaces as i " "from interfaces as i "
"left join nodes as n on n.node_id=i.node_id " "left join nodes as n on n.node_id=i.node_id "
"left join reserved as r on " "left join reserved as r on "
...@@ -4186,7 +4189,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp) ...@@ -4186,7 +4189,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
"left join node_hostkeys as nk on " "left join node_hostkeys as nk on "
" nk.node_id=n.node_id " " nk.node_id=n.node_id "
"where i.IP='%s' and i.role='ctrl'", /*XXX*/ "where i.IP='%s' and i.role='ctrl'", /*XXX*/
25, inet_ntoa(ipaddr)); 26, inet_ntoa(ipaddr));
} }
if (!res) { if (!res) {
...@@ -4224,6 +4227,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp) ...@@ -4224,6 +4227,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
if (row[4] && row[5]) { if (row[4] && row[5]) {
strncpy(reqp->pid, row[4], sizeof(reqp->pid)); strncpy(reqp->pid, row[4], sizeof(reqp->pid));
strncpy(reqp->eid, row[5], sizeof(reqp->eid)); strncpy(reqp->eid, row[5], sizeof(reqp->eid));
reqp->exptidx = atoi(row[25]);
reqp->allocated = 1; reqp->allocated = 1;
if (row[6]) if (row[6])
...@@ -7102,10 +7106,10 @@ COMMAND_PROTOTYPE(doportregister) ...@@ -7102,10 +7106,10 @@ COMMAND_PROTOTYPE(doportregister)
* Register port for the service. * Register port for the service.
*/ */
if (mydb_update("replace into port_registration set " if (mydb_update("replace into port_registration set "
" pid='%s', eid='%s', " " pid='%s', eid='%s', exptidx=%d, "
" service='%s', node_id='%s', port='%d'", " service='%s', node_id='%s', port='%d'",
reqp->pid, reqp->eid, service, reqp->pid, reqp->eid, reqp->exptidx,
reqp->nodeid, port)) { service, reqp->nodeid, port)) {
error("doportregister: %s: DB Error setting %s=%d!\n", error("doportregister: %s: DB Error setting %s=%d!\n",
reqp->nodeid, service, port); reqp->nodeid, service, port);
return 1; return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment