GithubHelp home page GithubHelp logo

Gracefully fail instead of `Killed` about libres HOT 3 CLOSED

pgdr avatar pgdr commented on August 29, 2024
Gracefully fail instead of `Killed`

from libres.

Comments (3)

pgdr avatar pgdr commented on August 29, 2024

Just a quick question: shouldn't all these

if (job->active)
  do_a();
else
  do_b();

be contained within mutex_lock?

What about adding something like this?

diff --git a/libjob_queue/src/local_driver.c b/libjob_queue/src/local_driver.c
index 19d2471..bcc8261 100644
--- a/libjob_queue/src/local_driver.c
+++ b/libjob_queue/src/local_driver.c
@@ -30,6 +30,7 @@
 #include <ert/job_queue/queue_driver.h>
 #include <ert/job_queue/local_driver.h>
 
+#include <ert/res_util/res_log.h>
 
 typedef struct local_job_struct local_job_type;
 
@@ -70,10 +71,19 @@ static local_job_type * local_job_alloc() {
 }
 
 static void local_job_free(local_job_type * job) {
-   if (job->active)
-      job->free_when_finished = true;
-   else
-      free(job);
+  res_log_add_message_str(LOG_INFO,
+                          "Local queue driver asked to free job ...");
+  pthread_mutex_lock( &driver->submit_lock );
+  if (job->active) {
+    res_log_add_message_str(LOG_INFO,
+                            "job is active, will free when finished");
+    job->free_when_finished = true;
+  } else {
+    res_log_add_message_str(LOG_INFO,
+                            "job is not active, freeing.");
+    free(job);
+  }
+  pthread_mutex_unlock( &driver->submit_lock );
 }

from libres.

joakim-hove avatar joakim-hove commented on August 29, 2024

shouldn't all these [...] be contained within mutex_lock?

I think it correct to do this unlocked; the locking should happen at the queue level - i.e. higher up; but I will take a hard look, you might be right!

from libres.

joakim-hove avatar joakim-hove commented on August 29, 2024

Is looked at a higher level: https://github.com/Statoil/libres/blob/master/libjob_queue/src/job_node.c#L594

from libres.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.