00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <SUM.h>
00025 #include <sys/socket.h>
00026 #include <sys/errno.h>
00027 #include <sys/time.h>
00028 #include <rpc/rpc.h>
00029 #include <rpc/pmap_clnt.h>
00030 #include <signal.h>
00031 #include <sum_rpc.h>
00032 #include <soi_error.h>
00033 #if defined(SUMS_TAPE_AVAILABLE) && SUMS_TAPE_AVAILABLE
00034 #include <tape.h>
00035 #endif
00036 #include <printk.h>
00037 #include <unistd.h>
00038 #include "serverdefs.h"
00039
00040 extern PART ptabx[];
00041
00042 void logkey();
00043 extern int errno;
00044 extern Sinfoarray sarray;
00045 static void sumprog_1();
00046 static void sumprog_1_array();
00047 struct timeval TIMEOUT = { 10, 0 };
00048 uint32_t rinfo;
00049 uint32_t sumprog, sumvers;
00050 int rrid = 0;
00051 float ftmp;
00052 char jsoc_machine[MAX_STR];
00053 static struct timeval first[4], second[4];
00054
00055 FILE *logfp;
00056 CLIENT *current_client, *clnttape, *clnttape_old;
00057 SVCXPRT *glb_transp;
00058 char *dbname;
00059 char thishost[MAX_STR];
00060 char usedhost[MAX_STR];
00061 char hostn[MAX_STR];
00062 char logname[MAX_STR];
00063 char newlogname[MAX_STR];
00064 char datestr[32];
00065 char timetag[32];
00066 int thispid;
00067 int soi_errno = NO_ERROR;
00068 int debugflg = 0;
00069 int sim = 0;
00070 int tapeoffline = 0;
00071 int newlog = 0;
00072 int logcnt = 0;
00073
00074
00075 void StartTimer(int n)
00076 {
00077 gettimeofday (&first[n], NULL);
00078 }
00079
00080 float StopTimer(int n)
00081 {
00082 gettimeofday (&second[n], NULL);
00083 if (first[n].tv_usec > second[n].tv_usec) {
00084 second[n].tv_usec += 1000000;
00085 second[n].tv_sec--;
00086 }
00087 return (float) (second[n].tv_sec-first[n].tv_sec) +
00088 (float) (second[n].tv_usec-first[n].tv_usec)/1000000.0;
00089 }
00090
00091
00092 void open_log(char *filename)
00093 {
00094 if((logfp=fopen(filename, "a+")) == NULL) {
00095 fprintf(stderr, "Can't open the log file %s\n", filename);
00096 }
00097 }
00098
00099
00100
00101
00102 char *datestring()
00103 {
00104 struct timeval tvalr;
00105 struct tm *t_ptr;
00106
00107 gettimeofday(&tvalr, NULL);
00108 t_ptr = localtime((const time_t *)&tvalr);
00109 sprintf(datestr, "%s", asctime(t_ptr));
00110 datestr[19] = (char)NULL;
00111 return(&datestr[4]);
00112 }
00113
00114
00115 char *gettimetag()
00116 {
00117 struct timeval tvalr;
00118 struct tm *t_ptr;
00119
00120 gettimeofday(&tvalr, NULL);
00121 t_ptr = localtime((const time_t *)&tvalr);
00122 sprintf(timetag, "%04d.%02d.%02d.%02d%02d%02d",
00123 (t_ptr->tm_year+1900), (t_ptr->tm_mon+1), t_ptr->tm_mday, t_ptr->tm_hour, t_ptr->tm_min, t_ptr->tm_sec);
00124 return(timetag);
00125 }
00126
00127
00128
00129
00130 int write_log(const char *fmt, ...)
00131 {
00132 va_list args;
00133 char string[4096];
00134
00135 va_start(args, fmt);
00136 vsprintf(string, fmt, args);
00137 if(logfp) {
00138 fprintf(logfp, string);
00139 fflush(logfp);
00140 }
00141 else
00142 fprintf(stderr, string);
00143 va_end(args);
00144 return(0);
00145 }
00146
00147
00148 void sighandler(sig)
00149 int sig;
00150 {
00151 printf("sig = %d\n", sig);
00152 if(sig == SIGTERM) {
00153 write_log("*** %s sum_svc got SIGTERM. Exiting.\n", datestring());
00154 exit(1);
00155 }
00156 if(sig == SIGINT) {
00157 write_log("*** %s sum_svc got SIGINT. Exiting.\n", datestring());
00158 DS_DisConnectDB();
00159 exit(1);
00160 }
00161 write_log("*** %s sum_svc got an illegal signal %d, ignoring...\n",
00162 datestring(), sig);
00163 if (signal(SIGINT, SIG_IGN) != SIG_IGN)
00164 signal(SIGINT, sighandler);
00165 if (signal(SIGALRM, SIG_IGN) != SIG_IGN)
00166 signal(SIGALRM, sighandler);
00167 }
00168
00169
00170
00171
00172 void usr1_sig(int sig)
00173 {
00174 write_log("%s usr1_sig received by xsum_svc\n", datestring());
00175
00176 logcnt++;
00177
00178 write_log("%s Closing the current log file. Goodby.\n", datestring());
00179 fclose(logfp);
00180 sprintf(newlogname, "%s_%d", logname, logcnt);
00181 open_log(newlogname);
00182 write_log("\n## %s reopen log sum_svc on %s for pid = %d ##\n",
00183 datestring(), thishost, thispid);
00184
00185 signal(SIGUSR1, &usr1_sig);
00186 }
00187
00188
00189 void get_cmd(int argc, char *argv[])
00190 {
00191 int c;
00192 char *username, *cptr, *cptr2;
00193
00194 if(!(username = (char *)getenv("USER"))) username = "nouser";
00195 if(strcmp(username, SUMS_MANAGER)) {
00196 printf("!!NOTE: You must be user %s to run sum_svc!\n", SUMS_MANAGER);
00197 exit(1);
00198 }
00199
00200 while((--argc > 0) && ((*++argv)[0] == '-')) {
00201 while((c = *++argv[0])) {
00202 switch(c) {
00203 case 'd':
00204 debugflg=1;
00205 break;
00206 case 's':
00207 sim=1;
00208 break;
00209 case 'o':
00210 tapeoffline=1;
00211 break;
00212 default:
00213 break;
00214 }
00215 }
00216 }
00217 if(argc != 2) {
00218 printf("!!ERROR: program needs 2 args: dbname and logfilename. e.g:\n");
00219 printf("sum_svc jsoc_sums sum_svc_2011.06.06.140140.log\n");
00220 exit(1);
00221 }
00222 dbname = argv[0];
00223
00224
00225
00226 sprintf(logname, "%s/%s", SUMLOG_BASEDIR, argv[1]);
00227 if(cptr = strstr(logname, "_R")) {
00228 if(cptr2 = strstr(logname, "log_R")) {
00229 *(cptr2+3) = (char)NULL;
00230 logcnt = 0;
00231 open_log(logname);
00232 }
00233 else if(cptr2 = strstr(logname, "log_")) {
00234 *cptr= (char)NULL;
00235 open_log(logname);
00236 *(cptr2+3) = (char)NULL;
00237 cptr2 = cptr2 + 4;
00238 sscanf(cptr2, "%d", &logcnt);
00239 }
00240 else {
00241 printf("!!ERROR: called with NG log file name: %s\n", logname);
00242 exit(1);
00243 }
00244 }
00245 else { open_log(logname); }
00246 }
00247
00248
00249 void setup()
00250 {
00251 FILE *fplog;
00252 int tpid, i;
00253 char *cptr, *machine;
00254 char lfile[MAX_STR], acmd[MAX_STR], line[MAX_STR];
00255
00256
00257
00258
00259
00260 sprintf(thishost, "localhost");
00261 gethostname(hostn, 80);
00262 cptr = index(hostn, '.');
00263 if(cptr) *cptr = (char)NULL;
00264
00265 sumprog = SUMPROG;
00266 sumvers = SUMVERS;
00267 thispid = getpid();
00268 if(!(machine = (char *)getenv("JSOC_MACHINE"))) {
00269 sprintf(jsoc_machine, "NOTGIVEN");
00270 write_log("!!WARNING: No JSOC_MACHINE in env\n");
00271 write_log("SUMLIB_InfoGetArray() calls will fail\n");
00272 }
00273 else
00274 sprintf(jsoc_machine, "%s", machine);
00275
00276
00277 printk_set(write_log, write_log);
00278 write_log("\n## %s sum_svc on %s (%s) for pid = %d ##\n",
00279 datestring(), thishost, hostn, thispid);
00280
00281
00282 signal(SIGINT, sighandler);
00283 if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
00284 signal(SIGTERM, sighandler);
00285 if (signal(SIGALRM, SIG_IGN) != SIG_IGN)
00286 signal(SIGALRM, sighandler);
00287 signal(SIGUSR1, &usr1_sig);
00288
00289
00290
00291 sprintf(lfile, "/tmp/find_tview.log");
00292 sprintf(acmd, "ps -ef | grep %s 1> %s 2>&1", TAPEVIEWERNAME, lfile);
00293 if(system(acmd)) {
00294 write_log("**Can't execute %s.\n", acmd);
00295 return;
00296 }
00297 if((fplog=fopen(lfile, "r")) == NULL) {
00298 write_log("**Can't open %s to find any %s\n", lfile, TAPEVIEWERNAME);
00299 return;
00300 }
00301 while(fgets(line, 128, fplog)) {
00302 if(!(strstr(line, "perl"))) continue;
00303 sscanf(line, "%s %d", acmd, &tpid);
00304 sprintf(lfile, "%s/sum_restart_%d.touch", SUMLOG_BASEDIR, tpid);
00305 sprintf(acmd, "/bin/touch %s", lfile);
00306 write_log("%s\n", acmd);
00307 system(acmd);
00308 }
00309 fclose(fplog);
00310 }
00311
00312
00313 void sumbye(void) {
00314 printf("sumbye() called by atexit() at %s\n", datestring());
00315 write_log("sumbye() called by atexit() at %s\n", datestring());
00316 }
00317
00318
00319 int main(int argc, char *argv[])
00320 {
00321 register SVCXPRT *transp;
00322 int i;
00323 pid_t pid;
00324 char dsvcname[80], cmd[128];
00325 char *args[5], pgport[32];
00326 char *simmode;
00327
00328 get_cmd(argc, argv);
00329 printf("\nPlease wait for sum_svc and tape inventory to initialize...\n");
00330 setup();
00331 if(atexit(sumbye)) {
00332 printf("Can't register sumbye() function in atexit()\n");
00333 }
00334
00335
00336 (void) pmap_unset(SUMPROG, SUMVERS);
00337 transp = (SVCXPRT *)svctcp_create(RPC_ANYSOCK, 0, 0);
00338 if (transp == NULL) {
00339 write_log("***cannot create tcp service\n");
00340 exit(1);
00341 }
00342 write_log("svctcp_create() port# = %u\n", transp->xp_port);
00343 if (!svc_register(transp, SUMPROG, SUMVERS, sumprog_1, IPPROTO_TCP)) {
00344 write_log("***unable to register (SUMPROG, SUMVERS, tcp)\n");
00345 exit(1);
00346 }
00347
00348
00349
00350 if(!(simmode = (char *)getenv("SUMSIMMODE"))) {
00351 sprintf(pgport, SUMPGPORT);
00352 setenv("SUMPGPORT", pgport, 1);
00353 write_log("xsum_svc sets SUMPGPORT env to %s\n", pgport);
00354 }
00355 else {
00356 write_log("xsum_svc sim mode SUMPGPORT %s\n", (char *)getenv("SUMPGPORT"));
00357 }
00358
00359 #ifndef __LOCALIZED_DEFS__
00360
00361
00362
00363 if(!strcmp(hostn, "dcs0") || !strcmp(hostn, "dcs1") || !strcmp(hostn, "dcs2") || !strcmp(hostn, "dcs3")) {
00364 if((pid = fork()) < 0) {
00365 write_log("***Can't fork(). errno=%d\n", errno);
00366 exit(1);
00367 }
00368 else if(pid == 0) {
00369 write_log("execvp of tape_svc\n");
00370 args[0] = "tape_svc";
00371 if(tapeoffline) {
00372 args[1] = "-o";
00373 args[2] = dbname;
00374 args[3] = timetag;
00375 args[4] = NULL;
00376 }
00377 else if(sim) {
00378 args[1] = "-s";
00379 args[2] = dbname;
00380 args[3] = timetag;
00381 args[4] = NULL;
00382 }
00383 else {
00384 args[1] = dbname;
00385 args[2] = timetag;
00386 args[3] = NULL;
00387 }
00388 if(execvp(args[0], args) < 0) {
00389 write_log("***Can't execvp() tape_svc. errno=%d\n", errno);
00390 exit(1);
00391 }
00392 }
00393 sleep(4);
00394 for(i=0; i < MAX_DRIVES; i++) {
00395 if((pid = fork()) < 0) {
00396 write_log("***Can't fork(). errno=%d\n", errno);
00397 exit(1);
00398 }
00399 else if(pid == 0) {
00400 sprintf(dsvcname, "drive%d_svc", i);
00401 write_log("execvp of %s\n", dsvcname);
00402 args[0] = dsvcname;
00403 if(tapeoffline) {
00404 args[1] = "-o";
00405 args[2] = dbname;
00406 args[3] = timetag;
00407 args[4] = NULL;
00408 }
00409 else if(sim) {
00410 args[1] = "-s";
00411 args[2] = dbname;
00412 args[3] = timetag;
00413 args[4] = NULL;
00414 }
00415 else {
00416 args[1] = dbname;
00417 args[2] = timetag;
00418 args[3] = NULL;
00419 }
00420 if(execvp(args[0], args) < 0) {
00421 write_log("***Can't execvp() %s. errno=%d\n", dsvcname, errno);
00422 exit(1);
00423 }
00424 }
00425 }
00426 if((pid = fork()) < 0) {
00427 write_log("***Can't fork(). errno=%d\n", errno);
00428 exit(1);
00429 }
00430 else if(pid == 0) {
00431 write_log("execvp of robot0_svc\n");
00432 args[0] = "robot0_svc";
00433 args[1] = dbname;
00434 args[2] = timetag;
00435 args[3] = NULL;
00436 if(execvp(args[0], args) < 0) {
00437 write_log("***Can't execvp() robot0_svc. errno=%d\n", errno);
00438 exit(1);
00439 }
00440 }
00441 }
00442 #endif
00443 #ifdef __LOCALIZED_DEFS__
00444 if((pid = fork()) < 0) {
00445 write_log("***Can't fork(). errno=%d\n", errno);
00446 exit(1);
00447 }
00448 else if(pid == 0) {
00449 write_log("execvp of sum_rm\n");
00450 args[0] = "sum_rm";
00451 args[1] = dbname;
00452 args[2] = timetag;
00453 args[3] = NULL;
00454 if(execvp(args[0], args) < 0) {
00455 write_log("***Can't execvp() sum_rm. errno=%d\n", errno);
00456 exit(1);
00457 }
00458 }
00459 #endif
00460
00461 #ifndef __LOCALIZED_DEFS__
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479 if(strcmp(hostn, "xim") && strcmp(hostn, "n00") && strcmp(hostn, "d00") && strcmp(hostn, "n02")) {
00480
00481 printf("\nsum_svc waiting for tape servers to start (approx 10sec)...\n");
00482 sleep(13);
00483
00484 if(strcmp(hostn, SUMSVCHOST)) {
00485 clnttape = clnt_create(thishost, TAPEPROG, TAPEVERS, "tcp");
00486 strcpy(usedhost, thishost);
00487 }
00488 else {
00489 clnttape = clnt_create(TAPEHOST, TAPEPROG, TAPEVERS, "tcp");
00490 strcpy(usedhost, TAPEHOST);
00491 }
00492 if(!clnttape) {
00493 clnt_pcreateerror("Can't get client handle to tape_svc (xsum_svc)");
00494 write_log("tape_svc not there on %s\n", usedhost);
00495
00496 }
00497 clnttape_old = clnttape;
00498 }
00499
00501 if(!strcmp(hostn, "xim")) {
00502
00503 printf("\nsum_svc waiting for tape servers to start (approx 10sec)...\n");
00504 sleep(10);
00505
00506 if(strcmp(hostn, SUMSVCHOST)) {
00507 clnttape = clnt_create(thishost, TAPEPROG, TAPEVERS, "tcp");
00508 strcpy(usedhost, thishost);
00509 }
00510 else {
00511 clnttape = clnt_create(TAPEHOST, TAPEPROG, TAPEVERS, "tcp");
00512 strcpy(usedhost, TAPEHOST);
00513 }
00514 if(!clnttape) {
00515 clnt_pcreateerror("Can't get client handle to tape_svc (xsum_svc)");
00516 write_log("tape_svc not there on %s\n", usedhost);
00517
00518 }
00519 clnttape_old = clnttape;
00520 }
00521 #endif
00522
00523 if(SUM_Init(dbname)) {
00524 write_log("***Can't SUM_Init()\n");
00525 exit(1);
00526 }
00527 sleep(5);
00528 printf("sum_svc now available\n");
00529
00530
00531
00532
00533
00534 svc_run();
00535 write_log("!!Fatal Error: svc_run() returned in sum_svc\n");
00536 exit(1);
00537 }
00538
00539
00540
00541
00542
00543 static void
00544 sumprog_1(rqstp, transp)
00545 struct svc_req *rqstp;
00546 SVCXPRT *transp;
00547 {
00548 char procname[128];
00549 char newlogname[MAX_STR];
00550 uint64_t ck_client;
00551 uint64_t uid;
00552
00553
00554 union __svcargun {
00555 Rkey sumdo_1_arg;
00556 } argument;
00557 char *result, *call_err;
00558 enum clnt_stat clnt_stat;
00559
00560 bool_t (*xdr_argument)(), (*xdr_result)();
00561 char *(*local)();
00562
00563 if(rqstp->rq_proc == INFODOARRAY) {
00564 sumprog_1_array(rqstp, transp);
00565 return;
00566 }
00567
00568 switch (rqstp->rq_proc) {
00569 case NULLPROC:
00570 (void) svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL);
00571 return;
00572 break;
00573
00574
00575
00576
00577
00578
00579 case OPENDO:
00580 sprintf(procname, "OPENDO");
00581 xdr_argument = xdr_Rkey;
00582 xdr_result = xdr_uint32_t;
00583 local = (char *(*)()) opendo_1;
00584 break;
00585 case CONFIGDO:
00586 sprintf(procname, "CONFIGDO");
00587 xdr_argument = xdr_Rkey;
00588 xdr_result = xdr_uint32_t;
00589 local = (char *(*)()) configdo_1;
00590 break;
00591 case SHUTDO:
00592 sprintf(procname, "SHUTDO");
00593 xdr_argument = xdr_Rkey;
00594 xdr_result = xdr_uint32_t;
00595 local = (char *(*)()) shutdo_1;
00596 break;
00597 case ALLOCDO:
00598 sprintf(procname, "ALLOCDO");
00599 xdr_argument = xdr_Rkey;
00600 xdr_result = xdr_Rkey;
00601 local = (char *(*)()) allocdo_1;
00602 break;
00603 case INFODO:
00604 sprintf(procname, "INFODO");
00605 xdr_argument = xdr_Rkey;
00606 xdr_result = xdr_Rkey;
00607 local = (char *(*)()) infodo_1;
00608 break;
00609 case INFODOX:
00610 sprintf(procname, "INFODOX");
00611 xdr_argument = xdr_Rkey;
00612 xdr_result = xdr_Rkey;
00613 local = (char *(*)()) infodoX_1;
00614
00615 break;
00616 case GETDO:
00617 sprintf(procname, "GETDO");
00618 xdr_argument = xdr_Rkey;
00619 xdr_result = xdr_Rkey;
00620 local = (char *(*)()) getdo_1;
00621 break;
00622 case PUTDO:
00623 sprintf(procname, "PUTDO");
00624 xdr_argument = xdr_Rkey;
00625 xdr_result = xdr_Rkey;
00626 local = (char *(*)()) putdo_1;
00627 break;
00628 case CLOSEDO:
00629 sprintf(procname, "CLOSEDO");
00630 xdr_argument = xdr_Rkey;
00631 xdr_result = xdr_uint32_t;
00632 local = (char *(*)()) closedo_1;
00633 break;
00634 case SUMRESPDO:
00635 sprintf(procname, "SUMRESPDO");
00636 xdr_argument = xdr_Rkey;
00637 xdr_result = xdr_Rkey;
00638 local = (char *(*)()) sumrespdo_1;
00639 break;
00640 case DELSERIESDO:
00641 sprintf(procname, "DELSERIESDO");
00642 xdr_argument = xdr_Rkey;
00643 xdr_result = xdr_uint32_t;
00644 local = (char *(*)()) delseriesdo_1;
00645 break;
00646 case NOPDO:
00647 sprintf(procname, "NOPDO");
00648 xdr_argument = xdr_Rkey;
00649 xdr_result = xdr_uint32_t;
00650 local = (char *(*)()) nopdo_1;
00651 break;
00652 case TAPERECONNECTDO:
00653 sprintf(procname, "TAPERESTARTDO");
00654 xdr_argument = xdr_Rkey;
00655 xdr_result = xdr_uint32_t;
00656 local = (char *(*)()) tapereconnectdo_1;
00657 break;
00658 case SUMREPARTN:
00659 sprintf(procname, "SUMREPARTN");
00660 xdr_argument = xdr_Rkey;
00661 xdr_result = xdr_uint32_t;
00662 local = (char *(*)()) repartndo_1;
00663 break;
00664 default:
00665 write_log("**sumprog_1() dispatch default procedure %d,ignore\n", rqstp->rq_proc);
00666 svcerr_noproc(transp);
00667 return;
00668 }
00669 bzero((char *)&argument, sizeof(argument));
00670 if (!svc_getargs(transp, (xdrproc_t)xdr_argument, (char *)&argument)) {
00671 write_log("***Error on svc_getargs()\n");
00672 svcerr_decode(transp);
00673
00674
00675
00676
00677 svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL);
00678 return;
00679
00680 }
00681 glb_transp = transp;
00682 result = (*local)(&argument, rqstp);
00683
00684
00685
00686 if(result) {
00687 if(result == (char *)1) {
00688
00689 }
00690 else {
00691 if(debugflg) {
00692 write_log("\n###KEYLIST at return in sum_svc\n");
00693 keyiterate(logkey, (KEY *)result);
00694 }
00695 if(current_client == 0) {
00696 write_log("***Error on clnt_call() back to orig sum_svc caller\n");
00697 write_log(" current_client was NULL\n");
00698 }
00699 else {
00700 ck_client = ((uint64_t)current_client & 0xfc00000000000000) >> 58;
00701 if(!((ck_client == 0) || (ck_client == 0x3f))) {
00702 write_log("***Error invalid current_client\n");
00703
00704
00705 }
00706 else {
00707 clnt_stat=clnt_call(current_client, RESPDO,(xdrproc_t)xdr_result,
00708 result, (xdrproc_t)xdr_void, 0, TIMEOUT);
00709 if(clnt_stat != RPC_SUCCESS) {
00710 if(clnt_stat != RPC_TIMEDOUT) {
00711 clnt_perrno(clnt_stat);
00712 write_log("***Error on clnt_call() back to RESPDO procedure\n");
00713 if(findkey(result, "uid")) {
00714 uid = getkey_uint64(result, "uid");
00715 write_log("***The original client caller has probably exited. Its uid=%lu\n", uid);
00716 }
00717 else {
00718 write_log("***The original client caller has probably exited\n");
00719 }
00720 call_err = clnt_sperror(current_client, "Err");
00721 write_log("%s\n", call_err);
00722
00723 }
00724 else {
00725 write_log("Timeout ignored on RESPDO back to current_client\n");
00726 }
00727 }
00728 clnt_destroy(current_client);
00729 }
00730 }
00731 freekeylist((KEY **)&result);
00732 }
00733 }
00734 else {
00735 }
00736 if (!svc_freeargs(transp, (xdrproc_t)xdr_argument, (char *)&argument)) {
00737 write_log("**unable to free arguments\n");
00738
00739 }
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755 return;
00756 }
00757
00758
00759
00760 static void
00761 sumprog_1_array(rqstp, transp)
00762 struct svc_req *rqstp;
00763 SVCXPRT *transp;
00764 {
00765 char procname[128];
00766 uint64_t ck_client;
00767 uint64_t uid;
00768
00769
00770 union __svcargun {
00771 Sunumarray sumdo_1_arg;
00772 } argument;
00773 char *result, *call_err;
00774 enum clnt_stat clnt_stat;
00775
00776 bool_t (*xdr_argument)(), (*xdr_result)();
00777 char *(*local)();
00778
00779 switch (rqstp->rq_proc) {
00780 case INFODOARRAY:
00781 sprintf(procname, "INFODOARRAY");
00782 xdr_argument = xdr_Sunumarray;
00783 xdr_result = xdr_Rkey;
00784 local = (char *(*)()) infodoArray_1;
00785 break;
00786 default:
00787 write_log("**sumprog_1_array() dispatch default procedure %d,ignore\n", rqstp->rq_proc);
00788 svcerr_noproc(transp);
00789 return;
00790 }
00791 bzero((char *)&argument, sizeof(argument));
00792 if (!svc_getargs(transp, (xdrproc_t)xdr_argument, (char *)&argument)) {
00793 write_log("***Error on svc_getargs()\n");
00794 svcerr_decode(transp);
00795
00796
00797
00798
00799 svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL);
00800 return;
00801
00802 }
00803 glb_transp = transp;
00804 result = (*local)(&argument, rqstp);
00805
00806
00807
00808 if(result) {
00809 if(result == (char *)1) {
00810
00811 }
00812 else {
00813 if(debugflg) {
00814 }
00815 if(current_client == 0) {
00816 write_log("***Error on clnt_call() back to orig sum_svc caller\n");
00817 write_log(" current_client was NULL\n");
00818 }
00819 else {
00820 ck_client = ((uint64_t)current_client & 0xfc00000000000000) >> 58;
00821 if(!((ck_client == 0) || (ck_client == 0x3f))) {
00822 write_log("***Error invalid current_client\n");
00823
00824
00825 }
00826 else {
00827 clnt_stat=clnt_call(current_client, RESPDOARRAY,(xdrproc_t)xdr_result, result, (xdrproc_t)xdr_void, 0, TIMEOUT);
00828 if(clnt_stat != RPC_SUCCESS) {
00829 if(clnt_stat != RPC_TIMEDOUT) {
00830 clnt_perrno(clnt_stat);
00831 write_log("***Error on clnt_call() back to RESPDO procedure\n");
00832 if(findkey(result, "uid")) {
00833 uid = getkey_uint64(result, "uid");
00834 write_log("***The original client caller has probably exited. Its uid=%lu\n", uid);
00835 }
00836 else {
00837 write_log("***The original client caller has probably exited\n");
00838 }
00839 call_err = clnt_sperror(current_client, "Err");
00840 write_log("%s\n", call_err);
00841
00842 }
00843 else {
00844 write_log("Timeout ignored on RESPDO back to current_client\n");
00845 }
00846 }
00847 clnt_destroy(current_client);
00848 }
00849 }
00850 freekeylist((KEY **)&result);
00851 }
00852 }
00853 else {
00854 }
00855 if (!svc_freeargs(transp, (xdrproc_t)xdr_argument, (char *)&argument)) {
00856 write_log("**unable to free arguments\n");
00857
00858 }
00859
00860
00861 return;
00862 }