00001
00002
00003 #include "subStructFileClose.h"
00004 #include "miscServerFunct.h"
00005 #include "dataObjOpr.h"
00006
00007
00008
00009 #include "eirods_structured_object.h"
00010
00011 int
00012 rsSubStructFileClose (rsComm_t *rsComm, subStructFileFdOprInp_t *subStructFileCloseInp)
00013 {
00014 rodsServerHost_t *rodsServerHost;
00015 int remoteFlag;
00016 int status;
00017
00018 remoteFlag = resolveHost (&subStructFileCloseInp->addr, &rodsServerHost);
00019
00020 if (remoteFlag == LOCAL_HOST) {
00021 status = _rsSubStructFileClose (rsComm, subStructFileCloseInp);
00022 } else if (remoteFlag == REMOTE_HOST) {
00023 status = remoteSubStructFileClose (rsComm, subStructFileCloseInp,
00024 rodsServerHost);
00025 } else {
00026 if (remoteFlag < 0) {
00027 return (remoteFlag);
00028 } else {
00029 rodsLog (LOG_NOTICE,
00030 "rsSubStructFileClose: resolveHost returned unrecognized value %d",
00031 remoteFlag);
00032 return (SYS_UNRECOGNIZED_REMOTE_FLAG);
00033 }
00034 }
00035
00036 return (status);
00037 }
00038
00039 int
00040 remoteSubStructFileClose (rsComm_t *rsComm, subStructFileFdOprInp_t *subStructFileCloseInp,
00041 rodsServerHost_t *rodsServerHost)
00042 {
00043 int status;
00044
00045 if (rodsServerHost == NULL) {
00046 rodsLog (LOG_NOTICE,
00047 "remoteSubStructFileClose: Invalid rodsServerHost");
00048 return SYS_INVALID_SERVER_HOST;
00049 }
00050
00051 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00052 return status;
00053 }
00054
00055 status = rcSubStructFileClose (rodsServerHost->conn, subStructFileCloseInp);
00056
00057 if (status < 0) {
00058 rodsLog (LOG_NOTICE,
00059 "remoteSubStructFileClose: rcFileClose failed for fd %d",
00060 subStructFileCloseInp->fd);
00061 }
00062
00063 return status;
00064 }
00065
00066 int
00067 _rsSubStructFileClose( rsComm_t* _comm,
00068 subStructFileFdOprInp_t* _close_inp ) {
00069
00070
00071 eirods::structured_object struct_obj;
00072 struct_obj.comm( _comm );
00073 struct_obj.file_descriptor( _close_inp->fd );
00074
00075 struct_obj.resc_hier( eirods::EIRODS_LOCAL_USE_ONLY_RESOURCE );
00076
00077
00078
00079
00080 eirods::error close_err = fileClose( _comm, struct_obj );
00081 if( !close_err.ok() ) {
00082 std::stringstream msg;
00083 msg << "_rsSubStructFileClose - failed on call to fileClose for fd [ ";
00084 msg << struct_obj.file_descriptor();
00085 msg << " ]";
00086 eirods::log( ERROR( -1, msg.str() ) );
00087 return close_err.code();
00088
00089 } else {
00090 return close_err.code();
00091
00092 }
00093
00094 }
00095
00096