From: Manfred Spraul <manfred@colorfullife.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] support large pid values for ipc/sem.c
Date: Sat, 19 Oct 2002 17:03:02 +0200 [thread overview]
Message-ID: <3DB17426.5010505@colorfullife.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 202 bytes --]
ipc/sem.c assumes that pid values are 16 bit:
try_atomic_semop():
>
> curr->sempid = (curr->sempid << 16) | pid;
>
> undo:
> curr->sempid >>= 16;
>
What about the attached fix?
--
Manfred
[-- Attachment #2: patch-sem --]
[-- Type: text/plain, Size: 1853 bytes --]
--- 2.5/ipc/sem.c Sat Oct 19 11:40:17 2002
+++ build-2.5/ipc/sem.c Sat Oct 19 11:52:36 2002
@@ -263,39 +263,39 @@
for (sop = sops; sop < sops + nsops; sop++) {
curr = sma->sem_base + sop->sem_num;
sem_op = sop->sem_op;
-
- if (!sem_op && curr->semval)
+ result = curr->semval;
+
+ if (!sem_op && result)
goto would_block;
- curr->sempid = (curr->sempid << 16) | pid;
- curr->semval += sem_op;
- if (sop->sem_flg & SEM_UNDO)
- {
+ result += sem_op;
+ if (result < 0)
+ goto would_block;
+ if (result > SEMVMX)
+ goto out_of_range;
+ if (sop->sem_flg & SEM_UNDO) {
int undo = un->semadj[sop->sem_num] - sem_op;
/*
* Exceeding the undo range is an error.
*/
if (undo < (-SEMAEM - 1) || undo > SEMAEM)
- {
- /* Don't undo the undo */
- sop->sem_flg &= ~SEM_UNDO;
goto out_of_range;
- }
- un->semadj[sop->sem_num] = undo;
}
- if (curr->semval < 0)
- goto would_block;
- if (curr->semval > SEMVMX)
- goto out_of_range;
+ curr->semval = result;
}
- if (do_undo)
- {
- sop--;
+ if (do_undo) {
result = 0;
goto undo;
}
-
+ sop--;
+ while (sop >= sops) {
+ sma->sem_base[sop->sem_num].sempid = pid;
+ if (sop->sem_flg & SEM_UNDO)
+ un->semadj[sop->sem_num] -= sop->sem_op;
+ sop--;
+ }
+
sma->sem_otime = CURRENT_TIME;
return 0;
@@ -310,13 +310,9 @@
result = 1;
undo:
+ sop--;
while (sop >= sops) {
- curr = sma->sem_base + sop->sem_num;
- curr->semval -= sop->sem_op;
- curr->sempid >>= 16;
-
- if (sop->sem_flg & SEM_UNDO)
- un->semadj[sop->sem_num] += sop->sem_op;
+ sma->sem_base[sop->sem_num].semval -= sop->sem_op;
sop--;
}
@@ -637,7 +633,7 @@
err = curr->semval;
goto out_unlock;
case GETPID:
- err = curr->sempid & 0xffff;
+ err = curr->sempid;
goto out_unlock;
case GETNCNT:
err = count_semncnt(sma,semnum);
reply other threads:[~2002-10-19 14:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DB17426.5010505@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome