11 #include "boost/bind.hpp"
12 #include "boost/function.hpp"
14 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG))
15 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE))
27 void set_bit(
int& f, const
unsigned int& b) {
31 bool get_bit(
const int& f,
const unsigned int& b) {
40 m_log(msgSvc(), name )
74 cur != props->
end(); cur++) {
75 if ( (*cur)->name() ==
"OutputLevel" ) {
112 <<
"unable to register ROOT file handler with FileMgr"
131 <<
"unable to register ROOT file handler with FileMgr"
160 <<
"At finalize, the following files remained open:"
164 m_log << *(itr->second) << endl;
184 ofs << itr->second->name() <<
" " << itr->second->tech() <<
" "
185 << itr->second->desc() <<
" " << itr->second->iflags() <<
endl;
195 for (it3=fs.
begin(); it3!=fs.
end(); ++it3) {
196 ofs << (it3)->
name() <<
" " << (it3)->tech() <<
" " << (it3)->desc()
197 <<
" " << (it3)->iflags()
198 << ( (it3->isShared()) ?
" SHARED" :
"" )
243 <<
"Handler for IoTech " << tech <<
" already registered. Ignoring."
250 <<
"open handler for tech " << tech <<
" is NULL"
257 <<
"no close handler for tech " << tech <<
" registered"
264 <<
"no reopen handler for tech " << tech <<
" registered"
272 <<
"Successfully registered handler for tech \"" << tech <<
"\""
290 <<
" as it hasn't been registered!"
319 const IoFlags& flags,
Fd& fd,
void*& ptr,
322 return open(tech, caller, fname, desc, flags, fd, ptr, sh);
334 return open(tech, caller, fname, desc, flags, fd, dummy, sh);
346 return open(tech, caller, fname, desc, flags, dummy, ptr, sh);
356 const IoFlags& flags,
Fd& fd,
void*& ptr,
bool shared) {
377 <<
",\"" << fname <<
"\",\""
380 << ( shared ?
",shared" :
",unshared")
400 if (itr->second->tech() != tech) {
403 <<
" with tech " << tech
404 <<
", file already opened with different tech "
405 << itr->second->tech()
419 bool shareable(
true);
429 if ( shareable && fa->
flags().
match(flags,
false) ) {
454 }
catch (
const boost::bad_function_call&
err) {
457 << fname <<
" caught " << err.what() <<
endmsg;
462 << fname <<
" caught an unknown exception." <<
endmsg;
469 <<
"open of file \"" << fname <<
"\", tech: \"" << tech
470 <<
"\", flags: \"" << flags <<
"\" requested by "
472 <<
" failed. return code: " << r
475 FileAttr xfa(-1,fname,desc,tech,flags,0,
false);
489 if (fd == -1 && ptr == 0) {
491 <<
" and File Ptr are invalid" <<
endmsg;
496 for (itr = fitr.
first; itr != fitr.
second; ++itr) {
499 }
else if (*fa == *(itr->second) ) {
501 <<
"\" returned a pre-existing file with identical"
502 <<
" FileAttributes: " << *fa <<
endmsg;
506 <<
"\" returned a pre-existing file with different"
507 <<
" FileAttributes -"
508 <<
endl <<
"old: " << *(itr->second)
509 << endl <<
"new: " << *fa << endmsg;
519 <<
"at least one open callback action failed"
548 if (itr->second->fd() ==
fd) {
555 <<
"\" when calling close()"
561 IoTech tech = itr->second->tech();
570 m_log <<
MSG::ERROR <<
"no close(" << tech <<
",Fd) function registered"
583 if (it->second->fd() ==
fd) {
597 <<
i <<
" times with Fd " << fd <<
endmsg;
602 }
else if (
i == 1 || (
i>1 && !fa->
isShared()) ) {
609 }
catch (
const boost::bad_function_call& err) {
611 <<
" on file descriptor "
612 << fd <<
" caught " << err.what() <<
endmsg;
617 <<
" on file descriptor "
618 << fd <<
" caught an unknown exception." <<
endmsg;
625 <<
"close of file with FD \"" << fd
626 <<
"\", name: \"" << fa->
name()
627 <<
"\", tech: \"" << tech <<
"\" failed"
640 <<
"ref count < 0 when closing " << fa
641 <<
". This should never happen"
657 <<
"at least one close callback action failed"
684 if (itr->second->fptr() == vp) {
691 <<
"\" when calling close()"
696 IoTech tech = itr->second->tech();
704 m_log <<
MSG::ERROR <<
"no close(" << tech <<
",void*) function registered"
717 if (it->second->fptr() == vp) {
730 << i <<
" times with fptr " << vp <<
endmsg;
735 }
else if (i == 1 || (i>1 && !fa->
isShared()) ) {
741 }
catch (
const boost::bad_function_call& err) {
743 <<
" on file " << fa->
name()
744 <<
" caught " << err.what() <<
endmsg;
749 <<
" on file " << fa->
name()
750 <<
" caught an unknown exception." <<
endmsg;
757 <<
"close of file with ptr \"" << vp
758 <<
"\", name: \"" << fa->
name()
759 <<
"\", tech: \"" << tech <<
"\" failed"
770 <<
"ref count: " << i <<
" < 0 when closing " << fa
771 <<
". This should never happen"
787 <<
"at least one close callback action failed"
802 <<
"," << caller <<
")"
810 if (itr->second->fd() ==
fd) {
817 <<
"\" when calling reopen()"
834 m_log <<
MSG::ERROR <<
"no reopen(" << tech <<
",Fd) function registered"
844 }
catch (
const boost::bad_function_call& err) {
846 <<
" on file descriptor " << fd <<
" with flags "
848 <<
" caught " << err.what() <<
endmsg;
852 <<
" on file descriptor " << fd <<
" with flags "
854 <<
" caught an unknown exception." <<
endmsg;
860 <<
"reopen of file with FD \"" << fd
861 <<
"\", name: \"" << fa->
name()
862 <<
"\", tech: \"" << tech
863 <<
"\", flags: \"" << flags <<
"\" failed"
878 <<
"at least one reopen callback action failed"
892 <<
"," << caller <<
")"
899 if (itr->second->fptr() == vp) {
906 <<
"unregistered file ptr \"" << vp
907 <<
"\" when calling reopen()"
921 m_log <<
MSG::ERROR <<
"no reopen(" << tech <<
",void*) function registered"
928 }
catch (
const boost::bad_function_call& err) {
930 <<
" on file " << fa->
name() <<
" with flags "
932 <<
" caught " << err.what() <<
endmsg;
936 <<
" on file " << fa->
name() <<
" with flags "
938 <<
" caught an unknown exception." <<
endmsg;
944 <<
"reopen of file with ptr \"" << vp
945 <<
"\", name: \"" << fa->
name()
946 <<
"\", tech: \"" << tech
947 <<
"\", flags: \"" << flags <<
"\" failed"
962 <<
"at least one reopen callback action failed"
986 if ( (*it2)->name() ==
fname ) {
1003 if (itr->second->fd() ==
fd) {
1011 if ( (*it2)->fd() ==
fd ) {
1028 if (itr->second->fptr() == vp) {
1036 if ( (*it2)->fptr() == vp ) {
1063 if (
find(files.
begin(), files.
end(), (*it2)->name()) == files.
end()) {
1069 return files.
size();
1092 return files.
size();
1109 if (itr->second->tech() == tech &&
1118 if ( (*it2)->tech() == tech &&
1125 return files.
size();
1143 if (itr->second->tech() == tech) {
1151 if ( (*it2)->tech() == tech) {
1157 return files.
size();
1171 if (itr->second->tech() == tech || tech ==
UNKNOWN) {
1172 if ( itr->second->flags() == flags ) {
1183 if ( (*it2)->tech() == tech || tech ==
UNKNOWN) {
1184 if ( (*it2)->flags() == flags ) {
1193 return files.
size();
1206 if (itr->second->tech() == tech || tech ==
UNKNOWN) {
1207 if ( itr->second->flags() == flags ) {
1216 if ( (*it2)->tech() == tech || tech ==
UNKNOWN) {
1217 if ( (*it2)->flags() == flags ) {
1224 return files.
size();
1260 if (itr->second->tech() == tech) {
1279 if (itr->second->tech() == tech || tech ==
UNKNOWN) {
1280 if ( itr->second->flags() == flags ) {
1297 if (itr->second->fd() ==
fd) {
1298 return itr->second->name();
1314 if (itr->second->fptr() == vp) {
1315 return itr->second->name();
1334 if (itr->second->fd() != -1) {
1335 return itr->second->fd();
1350 if (itr->second->fptr() ==
fptr) {
1351 return itr->second->fd();
1368 if (itr->second->fptr() != 0) {
1369 return itr->second->fptr();
1384 if (itr->second->fd() ==
fd) {
1385 return itr->second->fptr();
1438 <<
"no handler for tech " << tech <<
" registered"
1455 <<
"no file \"" << fname <<
"\" registered. Cannot determine tech"
1461 IoTech tech = itr->second->tech();
1464 while( itr != fitr.
second ) {
1465 if ( itr->second->tech() != tech ) {
1467 <<
"multiple technologies registered for file \"" << fname
1468 <<
"\". Cannot determine handler" <<
endmsg;
1484 <<
"Listing registered handlers:" <<
endl;
1489 m_log <<
" " << itr->first << endl;
1525 <<
" for tech " << t << endmsg;
1554 if (m.
size() != 0) {
1555 m_log <<
" --- Tech: ";
1557 m_log <<
"ALL ---" << endl;
1559 m_log << t <<
" ---" << endl;
1563 for (iia = m.
begin() ; iia != m.
end(); ++iia) {
1564 if (iia->second.size() != 0) {
1568 it2 != iia->second.end(); ++it2) {
1570 m_log <<
" " << iia->first <<
" "
1619 if (m[a].size() == 0) {
1625 <<
"executing " << m[a].
size() <<
" " << a
1646 itr != m[a].
end(); ++itr) {
1650 << itr->second <<
endmsg;
1652 if ( (((itr->first))(fa,caller)).isFailure() ) {
1654 << itr->second <<
" on " << *fa
1655 <<
" failed during " << a <<
" action"
1683 ((fold &
Io::WRITE) != 0 && (fnew & Io::WRITE) != 0) ||
1684 ((fold &
Io::RDWR) != 0 && (fnew & Io::RDWR) != 0) ) {
1728 m_log <<
" " << it2->first;
1730 m_log <<
" ALL" << endl;