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)  

rsFileClose.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See fileClose.h for a description of this API call.*/
5 
6 #include "fileClose.h"
7 #include "miscServerFunct.hpp"
8 #include "rsGlobalExtern.hpp"
9 #include "rsFileClose.hpp"
10 
11 // =-=-=-=-=-=-=-
12 #include "irods_log.hpp"
13 #include "irods_file_object.hpp"
14 #include "irods_stacktrace.hpp"
15 
16 
17 int
18 rsFileClose( rsComm_t *rsComm, fileCloseInp_t *fileCloseInp ) {
20  int remoteFlag;
21  int retVal;
22  remoteFlag = getServerHostByFileInx( fileCloseInp->fileInx,
23  &rodsServerHost );
24 
25  if ( remoteFlag == LOCAL_HOST ) {
26  retVal = _rsFileClose( rsComm, fileCloseInp );
27  }
28  else if ( remoteFlag == REMOTE_HOST ) {
29  retVal = remoteFileClose( rsComm, fileCloseInp, rodsServerHost );
30  }
31  else {
32  if ( remoteFlag < 0 ) {
33  return remoteFlag;
34  }
35  else {
37  "rsFileClose: resolveHost returned unrecognized value %d",
38  remoteFlag );
40  }
41  }
42 
43  /* Manually insert call-specific code here */
44 
45  freeFileDesc( fileCloseInp->fileInx );
46 
47  return retVal;
48 }
49 
50 int
51 remoteFileClose( rsComm_t *rsComm, fileCloseInp_t *fileCloseInp,
53  int status;
54  fileCloseInp_t remFileCloseInp;
55 
56  if ( rodsServerHost == NULL ) {
58  "remoteFileClose: Invalid rodsServerHost" );
60  }
61 
62  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
63  return status;
64  }
65 
66  memset( &remFileCloseInp, 0, sizeof( remFileCloseInp ) );
67  remFileCloseInp.fileInx = convL3descInx( fileCloseInp->fileInx );
68  status = rcFileClose( rodsServerHost->conn, &remFileCloseInp );
69 
70  if ( status < 0 ) {
72  "remoteFileClose: rcFileClose failed for %d, status = %d",
73  remFileCloseInp.fileInx, status );
74  }
75 
76  return status;
77 }
78 
80  rsComm_t* _comm,
81  fileCloseInp_t* _close_inp ) {
82  //Bounds-check the input descriptor index
83  if ( _close_inp->fileInx < 0 || static_cast<std::size_t>(_close_inp->fileInx) >= sizeof( FileDesc ) ) {
84  std::stringstream msg;
85  msg << "L3 descriptor index (into FileDesc) ";
86  msg << _close_inp->fileInx;
87  msg << " is out of range.";
88  irods::error err = ERROR( BAD_INPUT_DESC_INDEX, msg.str() );
89  irods::log(err);
90  return err.code();
91  }
92 
93  // trap bound stream case and close directly
94  // this is a weird case from rsExecCmd using
95  // the FD table
96  if ( 0 == strcmp(
98  FileDesc[ _close_inp->fileInx ].fileName ) ) {
99  return close( FileDesc[ _close_inp->fileInx ].fd );
100  }
101 
102  // call the resource plugin close operation
103  irods::file_object_ptr file_obj(
104  new irods::file_object(
105  _comm,
106  FileDesc[ _close_inp->fileInx ].objPath,
107  FileDesc[ _close_inp->fileInx ].fileName,
108  FileDesc[ _close_inp->fileInx ].rescHier,
109  FileDesc[ _close_inp->fileInx ].fd,
110  0, 0 ) );
111  file_obj->in_pdmo( _close_inp->in_pdmo );
112 
113  irods::error close_err = fileClose( _comm, file_obj );
114  // log an error, if any
115  if ( !close_err.ok() ) {
116  std::stringstream msg;
117  msg << "fileClose failed for [";
118  msg << _close_inp->fileInx;
119  msg << "]";
120  irods::log(PASSMSG( msg.str(), close_err ));
121  }
122 
123  return close_err.code();
124 
125 } // _rsFileClose
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
SYS_UNRECOGNIZED_REMOTE_FLAG
@ SYS_UNRECOGNIZED_REMOTE_FLAG
Definition: rodsErrorTable.h:88
irods_file_object.hpp
irods_stacktrace.hpp
getServerHostByFileInx
int getServerHostByFileInx(int fileInx, rodsServerHost_t **rodsServerHost)
Definition: fileOpr.cpp:99
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
_rsFileClose
int _rsFileClose(rsComm_t *_comm, fileCloseInp_t *_close_inp)
Definition: rsFileClose.cpp:79
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
FileCloseInp::in_pdmo
char in_pdmo[(1024+64)]
Definition: fileClose.h:8
fileDesc_t::rescHier
char * rescHier
Definition: fileOpr.hpp:28
rsFileClose.hpp
fileClose.h
FileCloseInp
Definition: fileClose.h:6
rsGlobalExtern.hpp
irods::error::code
long long code() const
Definition: irods_error.cpp:194
FileCloseInp::fileInx
int fileInx
Definition: fileClose.h:7
fileDesc_t::objPath
char * objPath
Definition: fileOpr.hpp:29
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
convL3descInx
int convL3descInx(int l3descInx)
Definition: objDesc.cpp:571
svrToSvrConnect
int svrToSvrConnect(rsComm_t *rsComm, rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:106
freeFileDesc
int freeFileDesc(int fileInx)
Definition: fileOpr.cpp:72
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
irods::log
void log(const error &)
Definition: irods_log.cpp:13
rcFileClose
int rcFileClose(rcComm_t *conn, fileCloseInp_t *fileCloseInp)
Definition: rcFileClose.cpp:23
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
fileClose
irods::error fileClose(rsComm_t *, irods::first_class_object_ptr)
Definition: fileDriver.cpp:147
rsFileClose
int rsFileClose(rsComm_t *rsComm, fileCloseInp_t *fileCloseInp)
Definition: rsFileClose.cpp:18
BAD_INPUT_DESC_INDEX
@ BAD_INPUT_DESC_INDEX
Definition: rodsErrorTable.h:266
remoteFileClose
int remoteFileClose(rsComm_t *rsComm, fileCloseInp_t *fileCloseInp, rodsServerHost_t *rodsServerHost)
Definition: rsFileClose.cpp:51
FileDesc
fileDesc_t FileDesc[1026]
Definition: irods_server_globals.cpp:28
STREAM_FILE_NAME
#define STREAM_FILE_NAME
Definition: fileOpr.hpp:23
irods::file_object
Definition: irods_file_object.hpp:19
rodsServerHost
Definition: rodsConnect.h:62
fileDesc_t::fd
int fd
Definition: fileOpr.hpp:32
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
fileDesc_t::fileName
char * fileName
Definition: fileOpr.hpp:27
irods_log.hpp