SysFera / vishnu

Modular and high-level middleware for tasks, files and information management in heterogeneous and distributed HPC environments
http://sysfera.github.com/vishnu.html
Other
4 stars 12 forks source link

bugfix: prevent vishnu sessions pid files corruption #373

Closed hguemar closed 10 years ago

hguemar commented 11 years ago

add a file lock to disable concurrent accesses to ~/.vishun/sessions/ file fixes #135

rchakode commented 11 years ago

test failed with boost 1.46.1.

The fail occured at core/src/util/sessionUtil.cpp:146 bi::file_lock sessionLock(file);

Exception raised ./bin/vishnu_connect: No such file or directory To get help, try << ./bin/vishnu_connect -h >>

hguemar commented 10 years ago

rebased against current zmq branch

rchakode commented 10 years ago

What about this PR? It doesn't work with boost 1.49.

hguemar commented 10 years ago

I rebased the PR and tested it on morgane against boost 1.46.1, you can reproduce it there using the following steps:

git clone https://github.com/hguemar/vishnu
git checkout zmq
mkdir build && cd build
ccmake28 -DBOOST_ROOT=/opt/boost146 ..
make -j12
rchakode commented 10 years ago

Ne marche toujours pas chez moi avec boost 1.49 et ubuntu 12.04 Quand j'applique le patch : ./bin/vishnu_connect: No such file or directory To get help, try << ./bin/vishnu_connect -h >>

_Je ne sais pas si c'est spécifique à ma machine. _

hguemar commented 10 years ago

Tu peux essayer sur morgane, j'ai également rajouté Boost 1.49 (/opt/boost149), j'arrive à lancer un umssed et me connecter à vishnu.

rchakode commented 10 years ago

c'est certainement mon système, mais je ne saurais expliquer.

hguemar commented 10 years ago

je tente sur une VM morgane

hguemar commented 10 years ago

Testé sur une VM ubuntu 12.04.3 fraiche avec Boost 1.49, ça passe :/

rchakode commented 10 years ago

After further investigations the problem persists. Howeber, I can note that the code lacks of exception handling, notably for boost::interprocess::interprocess_exception.

When I add a try ... catch block as below, it seems that the connection succeed, but due to the lack of exception handling the program fails.

After this change :

./bin/vishnu_connect
No such file or directory 
sessionId: root-2014-Jan-16-11:18:02.921430:31905

Snippet

template <class T>
void
saveIntoFile(SessionContainer& allSessions, const char* file){
  try {
    bi::file_lock sessionLock(file);
    bi::scoped_lock<bi::file_lock> lock(sessionLock);
    std::ofstream ofile (file);
    T ar(ofile);

    ar << bs::make_nvp("sessions",allSessions);

    ofile.close();
  } catch (const bi::interprocess_exception& ex) {
    std::cout << ex.what() <<"\n";
  }
hguemar commented 10 years ago

Thank you for your insight, i'll modify the PR in that way.

rchakode commented 10 years ago

ok, merged