phase=0;
proceed=true;
while (proceed==true) {
+ (void) rou_alert(0,"%s JMPDBG phase='%d' connect=%d",OPEP,phase,connect);
switch (phase) {
case 0 : //lets lock table access
if (sql_lock(sqlptr,RMTTBL)==false) {
}
break;
case 1 : //updating remotes record with links
- if (sql_request(sqlptr,upd,RMTTBL,delta,rmtip)==0)
- phase++; //Record not existing
+ if (sql_request(sqlptr,upd,RMTTBL,delta,rmtip)==1)
+ phase++; //Record is existing
break;
case 2 : //Let create a record
if (sql_request(sqlptr,ins,RMTTBL,rmtip)!=1) {
(void) rou_alert(0,"%s Unable to create entry "
"for remote ip <%s> in table <%s> (DB trouble?)",
OPEP,rmtip,RMTTBL);
- phase+=2;
}
- break;
- case 3 : //Let update the record
- if (sql_request(sqlptr,ins,RMTTBL,rmtip)!=1) {
- (void) rou_alert(0,"%s Unable to create entry "
- "for remote ip <%s> in table <%s> (DB trouble?)",
- OPEP,rmtip,RMTTBL);
- phase++; //No need to return get the connexion number
+ else {
+ if (sql_request(sqlptr,ins,RMTTBL,rmtip)!=1) {
+ (void) rou_alert(0,"%s Unable to create entry "
+ "for remote ip <%s> in table <%s> (DB trouble?)",
+ OPEP,rmtip,RMTTBL);
+ }
}
break;
- case 4 : //lets find the the number of connection
+ case 3 : //lets find the the number of connection
if (sql_mngremote(sqlptr,sql_select,rmtip,&srv)==false) {
(void) rou_alert(0,"%s Unable to get record "
"for remote ip <%s> in table <%s> (DB trouble?)",
srv=sql_freesrv(srv);
}
break;
- case 5 : //unlock database
+ case 4 : //unlock database
(void) sql_unlock(sqlptr,true);
break;
default : //SAFE Guard