fix: push PQ error handling to caller

main
Sean McBride 4 years ago
parent 7384b2de1e
commit dfb1c65e93

@ -4,7 +4,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
__attribute__((noreturn)) void __attribute__((noreturn)) static inline void
panic(const char *format, ...) panic(const char *format, ...)
{ {
va_list args; va_list args;

@ -1,10 +1,12 @@
#include <stdint.h>
#include "current_sandbox.h"
#include "global_request_scheduler.h"
#include "local_runqueue.h" #include "local_runqueue.h"
#include "local_runqueue_minheap.h" #include "local_runqueue_minheap.h"
#include "global_request_scheduler.h" #include "panic.h"
#include "current_sandbox.h"
#include "priority_queue.h" #include "priority_queue.h"
#include <stdint.h>
__thread static struct priority_queue local_runqueue_minheap; __thread static struct priority_queue local_runqueue_minheap;
@ -63,7 +65,10 @@ local_runqueue_minheap_delete(struct sandbox *sandbox)
{ {
assert(sandbox != NULL); assert(sandbox != NULL);
int rc = priority_queue_delete(&local_runqueue_minheap, sandbox, "Runqueue"); int rc = priority_queue_delete(&local_runqueue_minheap, sandbox, "Runqueue");
assert(rc == 0); if (rc == -1) {
panic("Err: Thread Local %lu tried to delete sandbox %lu from runqueue, but was not present\n",
pthread_self(), sandbox->start_time);
}
} }
/** /**

@ -181,7 +181,7 @@ priority_queue_enqueue(struct priority_queue *self, void *value, char *name)
/** /**
* @param self - the priority queue we want to delete from * @param self - the priority queue we want to delete from
* @param value - the value we want to delete * @param value - the value we want to delete
* @returns 0 on success. -1 on not found. -2 on unable to take lock * @returns 0 on success. -1 on not found
*/ */
int int
priority_queue_delete(struct priority_queue *self, void *value, char *name) priority_queue_delete(struct priority_queue *self, void *value, char *name)
@ -198,12 +198,9 @@ priority_queue_delete(struct priority_queue *self, void *value, char *name)
did_delete = true; did_delete = true;
} }
} }
ck_spinlock_fas_unlock(&self->lock); ck_spinlock_fas_unlock(&self->lock);
assert(did_delete); if (!did_delete) return -1;
if (!did_delete) {
printf("[priority_queue_delete] Not found!\n");
return -1;
};
return 0; return 0;
} }

Loading…
Cancel
Save