#include <linux/time.h>
#include <linux/smp_lock.h>
#include <linux/security.h>
-#include <linux/vs_base.h>
-
+#include <linux/syscalls.h>
#include <asm/uaccess.h>
#include "util.h"
sma->sem_perm.mode = (semflg & S_IRWXUGO);
sma->sem_perm.key = key;
- sma->sem_perm.xid = current->xid;
+ sma->sem_perm.xid = vx_current_xid();
sma->sem_perm.security = NULL;
retval = security_sem_alloc(sma);
if (error <= 0) {
struct sem_queue *n;
remove_from_queue(sma,q);
- n = q->next;
q->status = IN_WAKEUP;
+ /*
+ * Continue scanning. The next operation
+ * that must be checked depends on the type of the
+ * completed operation:
+ * - if the operation modified the array, then
+ * restart from the head of the queue and
+ * check for threads that might be waiting
+ * for semaphore values to become 0.
+ * - if the operation didn't modify the array,
+ * then just continue.
+ */
+ if (q->alter)
+ n = sma->sem_pending;
+ else
+ n = q->next;
wake_up_process(q->sleeper);
/* hands-off: q will disappear immediately after
* writing q->status.
struct semid64_ds tbuf;
int id;
- if(semid >= sem_ids.size)
+ if(semid >= sem_ids.entries->size)
return -EINVAL;
memset(&tbuf,0,sizeof(tbuf));
goto out_unlock_free;
error = try_atomic_semop (sma, sops, nsops, un, current->tgid);
- if (error <= 0)
- goto update;
+ if (error <= 0) {
+ if (alter && error == 0)
+ update_queue (sma);
+ goto out_unlock_free;
+ }
/* We need to sleep on this operation, so we put the current
* task into the pending queue and go to sleep.
queue.undo = un;
queue.pid = current->tgid;
queue.id = semid;
+ queue.alter = alter;
if (alter)
append_to_queue(sma ,&queue);
else
remove_from_queue(sma,&queue);
goto out_unlock_free;
-update:
- if (alter)
- update_queue (sma);
out_unlock_free:
sem_unlock(sma);
out_free: