irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

rsApiHandler.cpp
Go to the documentation of this file.
1 
4 /* rsApiHandler.c - The server API Handler. handle RODS_API_REQ_T type
5  * messages
6  */
7 
8 #include "rsApiHandler.hpp"
9 #include "modDataObjMeta.h"
10 #include "rcMisc.h"
11 #include "miscServerFunct.hpp"
12 #include "regReplica.h"
13 #include "rodsErrorTable.h"
14 #include "unregDataObj.h"
15 #include "modAVUMetadata.h"
16 #include "sockComm.h"
17 #include "irods_re_structs.hpp"
18 #include "sslSockComm.h"
20 #include "apiNumber.h"
21 #include "api_plugin_number.h"
22 #include "client_api_whitelist.hpp"
23 
24 #include <boost/thread.hpp>
25 #include <boost/thread/mutex.hpp>
26 #include <boost/thread/condition.hpp>
27 #include <csetjmp>
28 jmp_buf Jenv;
29 
30 // =-=-=-=-=-=-=-
31 // irods includes
34 #include "irods_threads.hpp"
37 
38 #include <iterator>
39 #include <algorithm>
40 
41 int rsApiHandler(rsComm_t* rsComm,
42  int apiNumber,
43  bytesBuf_t* inputStructBBuf,
44  bytesBuf_t* bsBBuf)
45 {
46  memset(&rsComm->rError, 0, sizeof(rError_t));
47 
48  const int apiInx = apiTableLookup( apiNumber );
49 
50  // =-=-=-=-=-=-=-
51  // create a network object
53  irods::error ret = irods::network_factory( rsComm, net_obj );
54  if ( !ret.ok() ) {
55  irods::log( PASS( ret ) );
56  return apiInx;
57  }
58 
59  if (apiInx < 0) {
60  rodsLog(LOG_ERROR, "rsApiHandler: apiTableLookup of apiNumber %d failed", apiNumber);
61  // cannot use sendApiReply because it does not know apiInx
63  apiInx, rsComm->irodsProt );
64  return apiInx;
65  }
66 
67  rsComm->apiInx = apiInx;
68 
69  void *myOutStruct = NULL;
70  bytesBuf_t myOutBsBBuf;
71  memset( &myOutBsBBuf, 0, sizeof( bytesBuf_t ) );
72 
73  int status = chkApiVersion( apiInx );
74  if ( status < 0 ) {
75  sendApiReply( rsComm, apiInx, status, myOutStruct, &myOutBsBBuf );
76  return status;
77  }
78 
79  status = chkApiPermission( rsComm, apiInx );
80  if ( status < 0 ) {
82  "rsApiHandler: User has no permission for apiNumber %d", apiNumber );
83  sendApiReply( rsComm, apiInx, status, myOutStruct, &myOutBsBBuf );
84  return status;
85  }
86 
88 
89  /* some sanity check */
90  if ( inputStructBBuf->len > 0 && RsApiTable[apiInx]->inPackInstruct == NULL ) {
92  "rsApiHandler: input struct error 1 for apiNumber %d", apiNumber );
93  sendApiReply( rsComm, apiInx, SYS_API_INPUT_ERR, myOutStruct,
94  &myOutBsBBuf );
95  return SYS_API_INPUT_ERR;
96  }
97 
98  if ( inputStructBBuf->len <= 0 && RsApiTable[apiInx]->inPackInstruct != NULL ) {
100  "rsApiHandler: input struct error 2 for apiNumber %d", apiNumber );
101  sendApiReply( rsComm, apiInx, SYS_API_INPUT_ERR, myOutStruct,
102  &myOutBsBBuf );
103  return SYS_API_INPUT_ERR;
104  }
105 
106  if ( bsBBuf->len > 0 && RsApiTable[apiInx]->inBsFlag <= 0 ) {
108  "rsApiHandler: input byte stream error for apiNumber %d", apiNumber );
109  sendApiReply( rsComm, apiInx, SYS_API_INPUT_ERR, myOutStruct,
110  &myOutBsBBuf );
111  return SYS_API_INPUT_ERR;
112  }
113 
114  char *myInStruct = NULL;
115 
116  if ( inputStructBBuf->len > 0 ) {
117  status = unpackStruct( inputStructBBuf->buf, ( void ** )( static_cast< void * >( &myInStruct ) ),
118  ( char* )RsApiTable[apiInx]->inPackInstruct, RodsPackTable, rsComm->irodsProt );
119  if ( status < 0 ) {
121  "rsApiHandler: unpackStruct error for apiNumber %d, status = %d",
122  apiNumber, status );
123  sendApiReply( rsComm, apiInx, status, myOutStruct,
124  &myOutBsBBuf );
125  return status;
126  }
127  }
128 
129  /* ready to call the handler functions */
130 
131  irods::api_entry_ptr api_entry = RsApiTable[apiInx];
132  if ( !api_entry.get() ) {
133  rodsLog( LOG_ERROR, "Null handler encountered for api number %d in rsApiHandler.", apiNumber );
134  return SYS_API_INPUT_ERR;
135  }
136 
137  void *myArgv[4];
138  int numArg = 0;
139 
140  if ( RsApiTable[apiInx]->inPackInstruct != NULL ) {
141  myArgv[numArg] = myInStruct;
142  numArg++;
143  };
144 
145  if ( RsApiTable[apiInx]->inBsFlag != 0 ) {
146  myArgv[numArg] = bsBBuf;
147  numArg++;
148  };
149 
150  if ( RsApiTable[apiInx]->outPackInstruct != NULL ) {
151  myArgv[numArg] = ( void * ) &myOutStruct;
152  numArg++;
153  };
154 
155  if ( RsApiTable[apiInx]->outBsFlag != 0 ) {
156  myArgv[numArg] = ( void * ) &myOutBsBBuf;
157  numArg++;
158  };
159 
160  int retVal = 0;
161  if ( numArg == 0 ) {
162  retVal = api_entry->call_wrapper(
163  api_entry.get(),
164  rsComm );
165  }
166  else if ( numArg == 1 ) {
167  retVal = api_entry->call_wrapper(
168  api_entry.get(),
169  rsComm,
170  myArgv[0] );
171  }
172  else if ( numArg == 2 ) {
173  retVal = api_entry->call_wrapper(
174  api_entry.get(),
175  rsComm,
176  myArgv[0],
177  myArgv[1] );
178  }
179  else if ( numArg == 3 ) {
180  retVal = api_entry->call_wrapper(
181  api_entry.get(),
182  rsComm,
183  myArgv[0],
184  myArgv[1],
185  myArgv[2] );
186  }
187  else if ( numArg == 4 ) {
188  retVal = api_entry->call_wrapper(
189  api_entry.get(),
190  rsComm,
191  myArgv[0],
192  myArgv[1],
193  myArgv[2],
194  myArgv[3]);
195  }
196 
197  if ( retVal != SYS_NO_HANDLER_REPLY_MSG ) {
199  ( rsComm, apiInx, retVal, myOutStruct, &myOutBsBBuf );
200  }
201 
202  // =-=-=-=-=-=-=-
203  // clear the incoming packing instruction
204  if ( myInStruct != NULL ) {
205  if ( RsApiTable[apiInx]->clearInStruct ) {
206  RsApiTable[apiInx]->clearInStruct( myInStruct );
207  }
208 
209  free( myInStruct );
210  myInStruct = NULL;
211  }
212 
213  if ( retVal >= 0 && status < 0 ) {
214  return status;
215  }
216  else {
217  return retVal;
218  }
219 }
220 
221 int
222 sendAndProcApiReply( rsComm_t * rsComm, int apiInx, int status,
223  void * myOutStruct, bytesBuf_t * myOutBsBBuf ) {
224  int retval;
225 
226  retval = sendApiReply( rsComm, apiInx, status, myOutStruct, myOutBsBBuf );
227 
228  clearBBuf( myOutBsBBuf );
229  if ( myOutStruct != NULL ) {
230  free( myOutStruct );
231  }
232  freeRErrorContent( &rsComm->rError );
233 
234  /* check for portal operation */
235 
236  if ( rsComm->portalOpr != NULL ) {
237  handlePortalOpr( rsComm );
239  free( rsComm->portalOpr );
240  rsComm->portalOpr = NULL;
241  }
242 
243  return retval;
244 }
245 
246 int
247 sendApiReply( rsComm_t * rsComm, int apiInx, int retVal,
248  void * myOutStruct, bytesBuf_t * myOutBsBBuf ) {
249  int status = 0;
250  bytesBuf_t *outStructBBuf = NULL;
251  bytesBuf_t *myOutStructBBuf;
252  bytesBuf_t *rErrorBBuf = NULL;
253  bytesBuf_t *myRErrorBBuf;
254 
255  svrChkReconnAtSendStart( rsComm );
256 
257  if ( retVal == SYS_HANDLER_DONE_NO_ERROR ) {
258  /* not actually an error */
259  retVal = 0;
260  }
261 
262  // =-=-=-=-=-=-=-
263  // create a network object
265  irods::error ret = irods::network_factory( rsComm, net_obj );
266  if ( !ret.ok() ) {
267  irods::log( PASS( ret ) );
268  return ret.code();
269 
270  }
271 
272 
274  if ( RsApiTable[apiInx]->outPackInstruct != NULL && myOutStruct != NULL ) {
275 
276  status = packStruct( ( char * ) myOutStruct, &outStructBBuf,
277  ( char* )RsApiTable[apiInx]->outPackInstruct, RodsPackTable, FREE_POINTER,
278  rsComm->irodsProt );
279 
280  if ( status < 0 ) {
282  "sendApiReply: packStruct error, status = %d", status );
283  sendRodsMsg( net_obj, RODS_API_REPLY_T, NULL,
284  NULL, NULL, status, rsComm->irodsProt );
285  svrChkReconnAtSendEnd( rsComm );
286  return status;
287  }
288 
289  myOutStructBBuf = outStructBBuf;
290  }
291  else {
292  myOutStructBBuf = NULL;
293  }
294 
295  if ( RsApiTable[apiInx]->outBsFlag == 0 ) {
296  myOutBsBBuf = NULL;
297  }
298 
299  if ( rsComm->rError.len > 0 ) {
300  status = packStruct( ( char * ) &rsComm->rError, &rErrorBBuf,
301  "RError_PI", RodsPackTable, 0, rsComm->irodsProt );
302 
303  if ( status < 0 ) {
305  "sendApiReply: packStruct error, status = %d", status );
306  sendRodsMsg( net_obj, RODS_API_REPLY_T, NULL,
307  NULL, NULL, status, rsComm->irodsProt );
308  svrChkReconnAtSendEnd( rsComm );
309  freeBBuf( outStructBBuf );
310  freeBBuf( rErrorBBuf );
311  return status;
312  }
313 
314  myRErrorBBuf = rErrorBBuf;
315  }
316  else {
317  myRErrorBBuf = NULL;
318  }
319  ret = sendRodsMsg( net_obj, RODS_API_REPLY_T, myOutStructBBuf,
320  myOutBsBBuf, myRErrorBBuf, retVal, rsComm->irodsProt );
321  if ( !ret.ok() ) {
322  int status1;
323  irods::log( PASS( ret ) );
324 
325  if ( rsComm->reconnSock > 0 ) {
326  int savedStatus = ret.code();
327  boost::unique_lock< boost::mutex > boost_lock( *rsComm->thread_ctx->lock );
329  "sendApiReply: svrSwitchConnect. cliState = %d,agState=%d",
330  rsComm->clientState, rsComm->agentState );
331  status1 = svrSwitchConnect( rsComm );
332  boost_lock.unlock();
333  if ( status1 > 0 ) {
334  /* should not be here */
336  "sendApiReply: Switch connection and retry sendRodsMsg" );
337  ret = sendRodsMsg( net_obj, RODS_API_REPLY_T,
338  myOutStructBBuf, myOutBsBBuf, myRErrorBBuf,
339  retVal, rsComm->irodsProt );
340 
341  if ( ret.code() >= 0 ) {
343  "sendApiReply: retry sendRodsMsg succeeded" );
344  }
345  else {
346  status = savedStatus;
347  }
348  }
349  }
350  }
351 
352  svrChkReconnAtSendEnd( rsComm );
353 
354  freeBBuf( outStructBBuf );
355  freeBBuf( rErrorBBuf );
356 
357  return status;
358 }
359 
360 int
361 chkApiVersion( int apiInx ) {
362  char *cliApiVersion;
363 
365  if ( ( cliApiVersion = getenv( SP_API_VERSION ) ) != NULL ) {
366  if ( strcmp( cliApiVersion, RsApiTable[apiInx]->apiVersion ) != 0 ) {
368  "chkApiVersion:Client's API Version %s does not match Server's %s",
369  cliApiVersion, RsApiTable[apiInx]->apiVersion );
371  }
372  }
373  return 0;
374 }
375 
376 int chkApiPermission(rsComm_t* rsComm, int apiInx)
377 {
378  auto& api_table = irods::get_server_api_table();
379  auto api_entry = api_table[apiInx];
380  const auto xmsgSvrOnly = api_entry->clientUserAuth & XMSG_SVR_ONLY;
381  const auto xmsgSvrAlso = api_entry->clientUserAuth & XMSG_SVR_ALSO;
382 
383  if (ProcessType == XMSG_SERVER_PT) {
384  if ((xmsgSvrOnly + xmsgSvrAlso) == 0) {
385  rodsLog(LOG_ERROR, "chkApiPermission: xmsgServer not allowed to handle api %d", api_entry->apiNumber);
386  return SYS_NO_API_PRIV;
387  }
388  }
389  else if (xmsgSvrOnly != 0) {
390  rodsLog(LOG_ERROR, "chkApiPermission: non xmsgServer not allowed to handle api %d", api_entry->apiNumber);
391  return SYS_NO_API_PRIV;
392  }
393 
394  const int clientUserAuth = api_entry->clientUserAuth & 0xfff; // Remove XMSG_SVR_* flags
395  if (clientUserAuth > rsComm->clientUser.authInfo.authFlag) {
396  return SYS_NO_API_PRIV;
397  }
398 
399  const int proxyUserAuth = api_entry->proxyUserAuth & 0xfff;
400  if (proxyUserAuth > rsComm->proxyUser.authInfo.authFlag) {
401  return SYS_NO_API_PRIV;
402  }
403 
404  auto& whitelist = irods::client_api_whitelist::instance();
405 
406  if (whitelist.enforce(*rsComm) && !whitelist.contains(api_entry->apiNumber)) {
407  return SYS_NO_API_PRIV;
408  }
409 
410  return 0;
411 }
412 
413 static
414 int
416  if (rsComm == NULL) {
417  rodsLog(LOG_ERROR, "apply_acPostProcForParallelTransferReceived: NULL rsComm");
419  }
420  if (rsComm->portalOpr == NULL) {
421  rodsLog(LOG_ERROR, "apply_acPostProcForParallelTransferReceived: NULL rsComm->portalOpr");
423  }
424 
425  const int l3_index = rsComm->portalOpr->dataOprInp.destL3descInx;
426  if (l3_index < 3 || l3_index >= NUM_FILE_DESC) {
427  rodsLog(LOG_ERROR, "apply_acPostProcForParallelTransferReceived: bad l3 descriptor index %d", l3_index);
429  }
430 
431  const char* resource_hierarchy = FileDesc[l3_index].rescHier;
432  if (resource_hierarchy == NULL) {
433  rodsLog(LOG_ERROR, "apply_acPostProcForParallelTransferReceived: NULL resource_hierarchy");
435  }
436 
437  irods::hierarchy_parser hierarchy_parser;
438  irods::error err = hierarchy_parser.set_string(resource_hierarchy);
439  if (!err.ok()) {
440  rodsLog(LOG_ERROR, "apply_acPostProcForParallelTransferReceived: set_string error [%s]", err.result().c_str());
441  return err.status();
442  }
443 
444  std::string leaf_resource;
445  err = hierarchy_parser.last_resc(leaf_resource);
446  if (!err.ok()) {
447  rodsLog(LOG_ERROR, "apply_acPostProcForParallelTransferReceived: last_resc error [%s]", err.result().c_str());
448  return err.status();
449  }
450 
451  const char *args[] = {leaf_resource.c_str()};
452  ruleExecInfo_t rei;
453  memset(&rei, 0, sizeof(rei));
454  rei.rsComm = rsComm;
455  int ret = applyRuleArg("acPostProcForParallelTransferReceived", args, sizeof(args)/sizeof(args[0]), &rei, NO_SAVE_REI);
456  return ret;
457 }
458 
459 int
461  int oprType;
462  int status;
463 
464  if ( rsComm == NULL || rsComm->portalOpr == NULL ) {
465  return 0;
466  }
467 
468  oprType = rsComm->portalOpr->oprType;
469 
470  switch ( oprType ) {
471  case PUT_OPR:
472  case GET_OPR:
473  status = svrPortalPutGet( rsComm );
474  if (status >=0 && oprType == PUT_OPR) {
476  }
477  break;
478  default:
480  "handlePortalOpr: Invalid portal oprType: %d", oprType );
482  break;
483  }
484  return status;
485 }
486 
487 int
488 readAndProcClientMsg( rsComm_t * rsComm, int flags ) {
489  int status = 0;
490  msgHeader_t myHeader;
491  bytesBuf_t inputStructBBuf, bsBBuf, errorBBuf;
492 
493  bzero( &inputStructBBuf, sizeof( inputStructBBuf ) );
494  bzero( &bsBBuf, sizeof( bsBBuf ) );
495  bzero( &errorBBuf, sizeof( errorBBuf ) );
496 
497  svrChkReconnAtReadStart( rsComm );
498  /* everything else are set in readMsgBody */
499 
500  /* read the header */
501 
502  // =-=-=-=-=-=-=-
503  // create a network object
505  irods::error ret = irods::network_factory( rsComm, net_obj );
506  if ( !ret.ok() ) {
507  irods::log( PASS( ret ) );
508  return ret.code();
509  }
510 
511  if ( ( flags & READ_HEADER_TIMEOUT ) != 0 ) {
512  int retryCnt = 0;
513  struct timeval tv;
514  tv.tv_sec = READ_HEADER_TIMEOUT_IN_SEC;
515  tv.tv_usec = 0;
516 
517  while ( 1 ) {
518  ret = readMsgHeader( net_obj, &myHeader, &tv );
519  if ( !ret.ok() ) {
520  if ( isL1descInuse() && retryCnt < MAX_READ_HEADER_RETRY ) {
522  "readAndProcClientMsg:readMsgHeader error. status = %d", ret.code() );
523  retryCnt++;
524  continue;
525  }
526  if ( ret.code() == USER_SOCK_CONNECT_TIMEDOUT ) {
528  "readAndProcClientMsg: readMsgHeader by pid %d timedout",
529  getpid() );
530  return ret.code();
531  }
532  }
533  break;
534  } // while 1
535  }
536  else {
537  ret = readMsgHeader( net_obj, &myHeader, NULL );
538  }
539 
540  if ( !ret.ok() ) {
541  irods::log( PASS( ret ) );
542  /* attempt to accept reconnect. ENOENT result from * user cntl-C */
543  if ( rsComm->reconnSock > 0 ) {
544  int savedStatus = ret.code();
545  /* try again. the socket might have changed */
546  boost::unique_lock< boost::mutex > boost_lock( *rsComm->thread_ctx->lock );
548  "readAndProcClientMsg: svrSwitchConnect. cliState = %d,agState=%d",
549  rsComm->clientState, rsComm->agentState );
550  svrSwitchConnect( rsComm );
551  boost_lock.unlock();
552  ret = readMsgHeader( net_obj, &myHeader, NULL );
553  if ( !ret.ok() ) {
554  svrChkReconnAtReadEnd( rsComm );
555  return savedStatus;
556  }
557  }
558  else {
559  svrChkReconnAtReadEnd( rsComm );
560  return ret.code();
561  }
562  } // if !ret.ok()
563 
564  ret = readMsgBody( net_obj, &myHeader, &inputStructBBuf,
565  &bsBBuf, &errorBBuf, rsComm->irodsProt, NULL );
566  if ( !ret.ok() ) {
567  irods::log( PASS( ret ) );
568  svrChkReconnAtReadEnd( rsComm );
569  return ret.code();
570  }
571 
572  svrChkReconnAtReadEnd( rsComm );
573 
574  /* handler switch by msg type */
575 
576  if ( strcmp( myHeader.type, RODS_API_REQ_T ) == 0 ) {
577  status = rsApiHandler( rsComm, myHeader.intInfo, &inputStructBBuf,
578  &bsBBuf );
579  clearBBuf( &inputStructBBuf );
580  clearBBuf( &bsBBuf );
581  clearBBuf( &errorBBuf );
582 
583  if ( ( flags & RET_API_STATUS ) != 0 ) {
584  return status;
585  }
586  else {
587  return 0;
588  }
589  }
590  else if ( strcmp( myHeader.type, RODS_DISCONNECT_T ) == 0 ) {
592  "readAndProcClientMsg: received disconnect msg from client" );
593 
594  return DISCONN_STATUS;
595  }
596  else if ( strcmp( myHeader.type, RODS_RECONNECT_T ) == 0 ) {
598  "readAndProcClientMsg: received reconnect msg from client" );
599  /* call itself again. be careful */
600  status = readAndProcClientMsg( rsComm, flags );
601  return status;
602  }
603  else {
605  "agentMain: msg type %s not support by server",
606  myHeader.type );
608  }
609 }
610 
611 /* sendAndRecvBranchMsg - Break out the normal mode of
612  * clientReuest/serverReply protocol for handling API. Instead of returning
613  * to rsApiHandler() and send a API reply, it sends a reply directly to
614  * the client through sendAndProcApiReply.
615  * Then it loops though readAndProcClientMsg() to process additional
616  * clients requests until the status is SYS_HANDLER_DONE_NO_ERROR
617  * which is generated by a rcOprComplete() call by the client. The client
618  * must remember to send a rcOprComplete() call or the server will hang
619  * in this loop.
620  * The caller of this routine should return a SYS_NO_HANDLER_REPLY_MSG
621  * status to rsApiHandler() if the client is not expecting any more
622  * reply msg.
623  */
624 
625 int
626 sendAndRecvBranchMsg( rsComm_t * rsComm, int apiInx, int status,
627  void * myOutStruct, bytesBuf_t * myOutBsBBuf ) {
628  int retval;
629  int savedApiInx;
630 
631  savedApiInx = rsComm->apiInx;
632  retval = sendAndProcApiReply( rsComm, apiInx, status,
633  myOutStruct, myOutBsBBuf );
634  if ( retval < 0 ) {
636  "sendAndRecvBranchMsg: sendAndProcApiReply error. status = %d", retval );
637  rsComm->apiInx = savedApiInx;
638  return retval;
639  }
640 
641  while ( 1 ) {
642  retval = readAndProcClientMsg( rsComm, RET_API_STATUS );
643  if ( retval >= 0 || retval == SYS_NO_HANDLER_REPLY_MSG ) {
644  /* more to come */
645  continue;
646  }
647  else {
648  rsComm->apiInx = savedApiInx;
649  if ( retval == SYS_HANDLER_DONE_NO_ERROR ) {
650  return 0;
651  }
652  else {
653  return retval;
654  }
655  }
656  }
657 }
658 
659 int
660 svrSendCollOprStat( rsComm_t * rsComm, collOprStat_t * collOprStat ) {
661  int status;
662 
663  status = _svrSendCollOprStat( rsComm, collOprStat );
664 
667  "svrSendCollOprStat: client reply %d != %d.",
669  return UNMATCHED_KEY_OR_INDEX;
670  }
671  else {
672  return 0;
673  }
674 }
675 
676 int
677 _svrSendCollOprStat( rsComm_t * rsComm, collOprStat_t * collOprStat ) {
678  int myBuf;
679  int status;
680 
681  status = sendAndProcApiReply( rsComm, rsComm->apiInx,
682  SYS_SVR_TO_CLI_COLL_STAT, collOprStat, NULL );
683  if ( status < 0 ) {
685  "svrSendCollOprStat: sendAndProcApiReply failed. status = %d",
686  status );
687  return status;
688  }
689 
690  /* read 4 bytes */
692  status = sslRead(rsComm->sock, static_cast<void*>(&myBuf), 4, NULL, NULL, rsComm->ssl);
693  } else {
694  status = myRead(rsComm->sock, static_cast<void*>(&myBuf), 4, NULL, NULL );
695  }
696 
697  if ( status < 0 ) {
699  "_svrSendCollOprStat: read handshake failed. [%s] status = %d", rsComm->negotiation_results, status );
700  }
701  return ntohl( myBuf );
702 }
703 
704 int
706  collOprStat_t * collOprStat, int retval ) {
707  int status = retval;
708 
709  while ( status == SYS_SVR_TO_CLI_COLL_STAT ) {
710  status = _svrSendCollOprStat( rsComm, collOprStat );
712  status = _cliGetCollOprStat( conn, &collOprStat );
713  }
714  else {
715  int myBuf = htonl( status );
717  sslWrite(static_cast<void*>(&myBuf), 4, NULL, conn->ssl);
718  } else {
719  myWrite(conn->sock, static_cast<void*>(&myBuf), 4, NULL );
720  }
721  break;
722  }
723  }
724  return status;
725 }
726 
727 void
729  alarm( 0 );
730  if ( isL1descInuse() ) {
732  "readTimeoutHandler: read header by %d timed out. L1desc is busy.",
733  getpid() );
734  longjmp( Jenv, L1DESC_INUSE );
735  }
736  else {
738  "readTimeoutHandler: read header by %d has timed out.",
739  getpid() );
740  longjmp( Jenv, READ_HEADER_TIMED_OUT );
741  }
742 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
rcComm_t
Definition: rcConnect.h:95
NULL
#define NULL
Definition: rodsDef.h:70
sendApiReply
int sendApiReply(rsComm_t *rsComm, int apiInx, int retVal, void *myOutStruct, bytesBuf_t *myOutBsBBuf)
Definition: rsApiHandler.cpp:247
rsComm_t
Definition: rcConnect.h:145
myRead
int myRead(int sock, void *buf, int len, int *bytesRead, struct timeval *tv)
Definition: rcMisc.cpp:4651
rError_t::len
int len
Definition: rodsError.h:25
SYS_INTERNAL_NULL_INPUT_ERR
@ SYS_INTERNAL_NULL_INPUT_ERR
Definition: rodsErrorTable.h:92
DataOprInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:134
msgHeader
Definition: rodsDef.h:210
SYS_NO_API_PRIV
@ SYS_NO_API_PRIV
Definition: rodsErrorTable.h:81
readMsgBody
irods::error readMsgBody(irods::network_object_ptr, msgHeader_t *, bytesBuf_t *, bytesBuf_t *, bytesBuf_t *, irodsProt_t, struct timeval *)
Definition: sockComm.cpp:236
RODS_DISCONNECT_T
#define RODS_DISCONNECT_T
Definition: rodsDef.h:227
modDataObjMeta.h
BytesBuf::buf
void * buf
Definition: rodsDef.h:199
UNMATCHED_KEY_OR_INDEX
@ UNMATCHED_KEY_OR_INDEX
Definition: rodsErrorTable.h:244
rsComm_t::irodsProt
irodsProt_t irodsProt
Definition: rcConnect.h:146
svrSendCollOprStat
int svrSendCollOprStat(rsComm_t *rsComm, collOprStat_t *collOprStat)
Definition: rsApiHandler.cpp:660
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
msgHeader::type
char type[128]
Definition: rodsDef.h:211
PortalOpr::dataOprInp
dataOprInp_t dataOprInp
Definition: dataObjInpOut.h:199
sslSockComm.h
chkApiVersion
int chkApiVersion(int apiInx)
Definition: rsApiHandler.cpp:361
NO_SAVE_REI
#define NO_SAVE_REI
Definition: rodsDef.h:103
XMSG_SERVER_PT
#define XMSG_SERVER_PT
Definition: rodsDef.h:81
SYS_HANDLER_DONE_NO_ERROR
@ SYS_HANDLER_DONE_NO_ERROR
Definition: rodsErrorTable.h:878
irods::hierarchy_parser
Definition: irods_hierarchy_parser.hpp:14
rcMisc.h
irods_threads.hpp
PUT_OPR
#define PUT_OPR
Definition: dataObjInpOut.h:167
READ_HEADER_TIMEOUT
#define READ_HEADER_TIMEOUT
Definition: rsApiHandler.hpp:28
unpackStruct
int unpackStruct(const void *inPackStr, void **outStruct, const char *packInstName, const packInstruct_t *myPackTable, irodsProt_t irodsProt)
Definition: packStruct.cpp:63
rsComm_t::thread_ctx
struct thread_context * thread_ctx
Definition: rcConnect.h:171
RsApiTable
irods::api_entry_table RsApiTable
svrPortalPutGet
int svrPortalPutGet(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:389
readMsgHeader
irods::error readMsgHeader(irods::network_object_ptr, msgHeader_t *, struct timeval *)
Definition: sockComm.cpp:173
READ_HEADER_TIMED_OUT
#define READ_HEADER_TIMED_OUT
Definition: rsApiHandler.hpp:33
rsComm_t::clientState
procState_t clientState
Definition: rcConnect.h:174
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
_cliGetCollOprStat
int _cliGetCollOprStat(rcComm_t *conn, collOprStat_t **collOprStat)
Definition: procApiRequest.cpp:445
GET_OPR
#define GET_OPR
Definition: dataObjInpOut.h:168
fileDesc_t::rescHier
char * rescHier
Definition: fileOpr.hpp:28
ProcessType
int ProcessType
Definition: rcGlobal.cpp:16
RODS_RECONNECT_T
#define RODS_RECONNECT_T
Definition: rodsDef.h:228
isL1descInuse
int isL1descInuse()
Definition: objDesc.cpp:56
irods::api_entry_ptr
boost::shared_ptr< api_entry > api_entry_ptr
Definition: apiHandler.hpp:347
RuleExecInfo::rsComm
rsComm_t * rsComm
Definition: irods_re_structs.hpp:22
sendAndProcApiReply
int sendAndProcApiReply(rsComm_t *rsComm, int apiInx, int status, void *myOutStruct, bytesBuf_t *myOutBsBBuf)
Definition: rsApiHandler.cpp:222
BytesBuf::len
int len
Definition: rodsDef.h:198
irods_network_factory.hpp
Jenv
jmp_buf Jenv
Definition: rsApiHandler.cpp:28
client_api_whitelist.hpp
rsComm_t::reconnSock
int reconnSock
Definition: rcConnect.h:165
USER_API_VERSION_MISMATCH
@ USER_API_VERSION_MISMATCH
Definition: rodsErrorTable.h:269
rsComm_t::rError
rError_t rError
Definition: rcConnect.h:158
irods::error::code
long long code() const
Definition: irods_error.cpp:194
rError_t
Definition: rodsError.h:24
irods::network_factory
irods::error network_factory(rcComm_t *, irods::network_object_ptr &)
Definition: irods_network_factory.cpp:8
rsComm_t::apiInx
int apiInx
Definition: rcConnect.h:160
sslRead
int sslRead(int sock, void *buf, int len, int *bytesRead, struct timeval *tv, SSL *ssl)
Definition: sslSockComm.cpp:501
irods::hierarchy_parser::last_resc
error last_resc(std::string &_ret_resc) const
Definition: irods_hierarchy_parser.cpp:109
svrSendZoneCollOprStat
int svrSendZoneCollOprStat(rsComm_t *rsComm, rcComm_t *conn, collOprStat_t *collOprStat, int retval)
Definition: rsApiHandler.cpp:705
LOG_DEBUG
#define LOG_DEBUG
Definition: rodsLog.h:23
rsComm_t::proxyUser
userInfo_t proxyUser
Definition: rcConnect.h:152
XMSG_SVR_ALSO
#define XMSG_SVR_ALSO
Definition: rodsUser.h:39
myWrite
int myWrite(int sock, void *buf, int len, int *bytesWritten)
Definition: rcMisc.cpp:4610
rsComm_t::negotiation_results
char negotiation_results[(1024+64)]
Definition: rcConnect.h:185
collOprStat_t
Definition: objInfo.h:298
RET_API_STATUS
#define RET_API_STATUS
Definition: rsApiHandler.hpp:27
irods::get_server_api_table
api_entry_table & get_server_api_table()
Definition: irods_server_api_table.cpp:8
sslWrite
int sslWrite(void *buf, int len, int *bytesWritten, SSL *ssl)
Definition: sslSockComm.cpp:563
irods::CS_NEG_USE_SSL
const std::string CS_NEG_USE_SSL("CS_NEG_USE_SSL")
irods_server_api_table.hpp
applyRuleArg
int applyRuleArg(const char *action, const char *args[20], int argc, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:95
readTimeoutHandler
void readTimeoutHandler(int)
Definition: rsApiHandler.cpp:728
rsComm_t::ssl
SSL * ssl
Definition: rcConnect.h:181
SYS_SVR_TO_CLI_COLL_STAT
#define SYS_SVR_TO_CLI_COLL_STAT
Definition: rodsDef.h:110
irods::hierarchy_parser::set_string
error set_string(const std::string &_resc_hier)
Definition: irods_hierarchy_parser.cpp:36
rcComm_t::ssl
SSL * ssl
Definition: rcConnect.h:130
svrChkReconnAtSendStart
int svrChkReconnAtSendStart(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:2300
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
sendRodsMsg
irods::error sendRodsMsg(irods::network_object_ptr, const char *, bytesBuf_t *, bytesBuf_t *, bytesBuf_t *, int, irodsProt_t)
Definition: sockComm.cpp:1221
api_plugin_number.h
irods::client_api_whitelist::instance
static auto instance() -> client_api_whitelist &
Definition: client_api_whitelist.cpp:29
svrChkReconnAtReadStart
int svrChkReconnAtReadStart(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:2334
chkApiPermission
int chkApiPermission(rsComm_t *rsComm, int apiInx)
Definition: rsApiHandler.cpp:376
svrSwitchConnect
int svrSwitchConnect(rsComm_t *rsComm)
Definition: sockComm.cpp:1408
_svrSendCollOprStat
int _svrSendCollOprStat(rsComm_t *rsComm, collOprStat_t *collOprStat)
Definition: rsApiHandler.cpp:677
readAndProcClientMsg
int readAndProcClientMsg(rsComm_t *rsComm, int flags)
Definition: rsApiHandler.cpp:488
irods::log
void log(const error &)
Definition: irods_log.cpp:13
SYS_NO_HANDLER_REPLY_MSG
@ SYS_NO_HANDLER_REPLY_MSG
Definition: rodsErrorTable.h:879
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
rsComm_t::clientUser
userInfo_t clientUser
Definition: rcConnect.h:153
svrChkReconnAtReadEnd
int svrChkReconnAtReadEnd(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:2354
regReplica.h
rsComm_t::portalOpr
portalOpr_t * portalOpr
Definition: rcConnect.h:159
RodsPackTable
const packInstruct_t RodsPackTable[]
Definition: rodsPackTable.h:61
BytesBuf
Definition: rodsDef.h:197
rsComm_t::agentState
procState_t agentState
Definition: rcConnect.h:173
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
apiNumber.h
READ_HEADER_TIMEOUT_IN_SEC
#define READ_HEADER_TIMEOUT_IN_SEC
Definition: rsApiHandler.hpp:30
irods::api_entry_table
Definition: apiHandler.hpp:353
rsApiHandler
int rsApiHandler(rsComm_t *rsComm, int apiNumber, bytesBuf_t *inputStructBBuf, bytesBuf_t *bsBBuf)
Definition: rsApiHandler.cpp:41
FileDesc
fileDesc_t FileDesc[1026]
Definition: irods_server_globals.cpp:28
RODS_API_REQ_T
#define RODS_API_REQ_T
Definition: rodsDef.h:226
irods_hierarchy_parser.hpp
msgHeader::intInfo
int intInfo
Definition: rodsDef.h:215
svrChkReconnAtSendEnd
int svrChkReconnAtSendEnd(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:2320
irods::network_object_ptr
boost::shared_ptr< network_object > network_object_ptr
Definition: irods_network_object.hpp:78
DISCONN_STATUS
#define DISCONN_STATUS
Definition: rsApiHandler.hpp:18
SP_API_VERSION
#define SP_API_VERSION
Definition: rodsDef.h:262
apply_acPostProcForParallelTransferReceived
static int apply_acPostProcForParallelTransferReceived(rsComm_t *rsComm)
Definition: rsApiHandler.cpp:415
SYS_INVALID_PORTAL_OPR
@ SYS_INVALID_PORTAL_OPR
Definition: rodsErrorTable.h:101
apiTableLookup
int apiTableLookup(int apiNumber)
Definition: procApiRequest.cpp:461
RuleExecInfo
Definition: irods_re_structs.hpp:18
modAVUMetadata.h
irods_re_structs.hpp
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
DataOprInp::destL3descInx
int destL3descInx
Definition: dataObjInpOut.h:126
sendAndRecvBranchMsg
int sendAndRecvBranchMsg(rsComm_t *rsComm, int apiInx, int status, void *myOutStruct, bytesBuf_t *myOutBsBBuf)
Definition: rsApiHandler.cpp:626
packStruct
int packStruct(const void *inStruct, bytesBuf_t **packedResult, const char *packInstName, const packInstruct_t *myPackTable, int packFlag, irodsProt_t irodsProt)
Definition: packStruct.cpp:21
NUM_FILE_DESC
#define NUM_FILE_DESC
Definition: fileOpr.hpp:16
USER_SOCK_CONNECT_TIMEDOUT
@ USER_SOCK_CONNECT_TIMEDOUT
Definition: rodsErrorTable.h:268
irods::error::status
bool status() const
Definition: irods_error.cpp:187
FREE_POINTER
#define FREE_POINTER
Definition: packStruct.h:77
sockComm.h
rodsErrorTable.h
USER_MSG_TYPE_NO_SUPPORT
@ USER_MSG_TYPE_NO_SUPPORT
Definition: rodsErrorTable.h:257
L1DESC_INUSE
#define L1DESC_INUSE
Definition: rsApiHandler.hpp:32
freeBBuf
int freeBBuf(bytesBuf_t *myBBuf)
Definition: rcMisc.cpp:88
userInfo_t::authInfo
authInfo_t authInfo
Definition: rodsUser.h:70
MAX_READ_HEADER_RETRY
#define MAX_READ_HEADER_RETRY
Definition: rsApiHandler.hpp:34
rsApiHandler.hpp
SYS_FILE_DESC_OUT_OF_RANGE
@ SYS_FILE_DESC_OUT_OF_RANGE
Definition: rodsErrorTable.h:87
clearBBuf
int clearBBuf(bytesBuf_t *myBBuf)
Definition: rcMisc.cpp:101
authInfo_t::authFlag
int authFlag
Definition: rodsUser.h:42
clearKeyVal
int clearKeyVal(keyValPair_t *condInput)
Definition: rcMisc.cpp:1047
sockCommNetworkInterface.hpp
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
XMSG_SVR_ONLY
#define XMSG_SVR_ONLY
Definition: rodsUser.h:38
SYS_API_INPUT_ERR
@ SYS_API_INPUT_ERR
Definition: rodsErrorTable.h:82
rsComm_t::sock
int sock
Definition: rcConnect.h:147
thread_context::lock
boost::mutex * lock
Definition: irods_threads.hpp:12
irods::error::result
std::string result() const
Definition: irods_error.cpp:201
unregDataObj.h
handlePortalOpr
int handlePortalOpr(rsComm_t *rsComm)
Definition: rsApiHandler.cpp:460
freeRErrorContent
int freeRErrorContent(rError_t *myError)
Definition: rcMisc.cpp:182
irods_client_server_negotiation.hpp
rcComm_t::negotiation_results
char negotiation_results[(1024+64)]
Definition: rcConnect.h:125
SYS_CLI_TO_SVR_COLL_STAT_REPLY
#define SYS_CLI_TO_SVR_COLL_STAT_REPLY
Definition: rodsDef.h:111
RODS_API_REPLY_T
#define RODS_API_REPLY_T
Definition: rodsDef.h:230
PortalOpr::oprType
int oprType
Definition: dataObjInpOut.h:198
rcComm_t::sock
int sock
Definition: rcConnect.h:98