8000 Add NT patch. · rtpg/postgres@e966b4f · GitHub
[go: up one dir, main page]

Skip to content

Commit e966b4f

Browse files
committed
Add NT patch.
1 parent 9505391 commit e966b4f

File tree

1 file changed

+285
-0
lines changed

1 file changed

+285
-0
lines changed

src/win32/ipc.patch

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
*** ./ipc-daemon.c.orig Tue Dec 01 00:04:24 1998
2+
--- ./ipc-daemon.c Fri Sep 24 13:34:16 1999
3+
***************
4+
*** 270,285 ****
5+
{
6+
itoa(100*id+Index, LBuff) ;
7+
LHandle = OpenSemaphore(SEMAPHORE_ALL_ACCESS, FALSE, LBuff) ;
8+
! while (LAdrSem->current_nb[id].current_nb[Index] > 0 )
9+
! {
10+
! WaitForSingleObject(LHandle, 0) ;
11+
! LAdrSem->current_nb[id].current_nb[Index]-- ;
12+
! }
13+
! CloseHandle(LHandle) ;
14+
}
15+
LAdrSem->semary[id] = IPC_UNUSED ;
16+
LAdrSem->state[id] = 0 ;
17+
}
18+
else
19+
{
20+
for (Index = 0; Index < sma->sem_nsems; Index++)
21+
--- 270,284 ----
22+
{
23+
itoa(100*id+Index, LBuff) ;
24+
LHandle = OpenSemaphore(SEMAPHORE_ALL_ACCESS, FALSE, LBuff) ;
25+
! while (WaitForSingleObject(LHandle, 0) == WAIT_OBJECT_0)
26+
! ;
27+
! LAdrSem->current_nb[id].current_nb[Index] = 0;
28+
! CloseHandle(LHandle) ;
29+
}
30+
LAdrSem->semary[id] = IPC_UNUSED ;
31+
LAdrSem->state[id] = 0 ;
32+
}
33+
+ /*
34+
else
35+
{
36+
for (Index = 0; Index < sma->sem_nsems; Index++)
37+
***************
38+
*** 288,293 ****
39+
--- 287,293 ----
40+
LHandle = OpenSemaphore(SEMAPHORE_ALL_ACCESS, FALSE, LBuff) ;
41+
}
42+
}
43+
+ */
44+
}
45+
}
46+
47+
*** ./msg.c.orig Tue Dec 01 00:16:09 1998
48+
--- ./msg.c Fri Sep 17 12:50:50 1999
49+
***************
50+
*** 57,62 ****
51+
--- 57,77 ----
52+
static int GFirstMsg = 0; /*PCPC*/
53+
static int GFdMsg ; /*PCPC*/
54+
55+
+ /*****************************************/
56+
+ /* Initialization of static variables */
57+
+ /*****************************************/
58+
+ static pid_t GProcessId = 0;
59+
+ static void init_globals(void)
60+
+ {
61+
+ pid_t pid;
62+
+
63+
+ if (pid=getpid(), pid != GProcessId)
64+
+ {
65+
+ GFirstMsg = 0;
66+
+ msgbytes = msghdrs = msg_seq = used_queues = max_msqid = 0;
67+
+ GProcessId = pid;
68+
+ }
69+
+ }
70+
/************************************************************************/
71+
/* Demande d'acces a la zone partagee de gestion des semaphores */
72+
/************************************************************************/
73+
***************
74+
*** 79,84 ****
75+
--- 94,100 ----
76+
{
77+
int LRet ;
78+
79+
+ init_globals();
80+
if( GFirstMsg == 0 )
81+
{
82+
if( IsGSemMsgExist() )
83+
*** ./sem.c.orig Tue Dec 01 00:16:25 1998
84+
--- ./sem.c Fri Sep 17 12:47:11 1999
85+
***************
86+
*** 58,63 ****
87+
--- 58,78 ----
88+
static int GFirstSem = 0; /*PCPC*/
89+
static int GFdSem ; /*PCPC*/
90+
91+
+ static pid_t GProcessId = 0;
92+
+
93+
+ static void init_globals(void)
94+
+ {
95+
+ pid_t pid;
96+
+
97+
+ if (pid=getpid(), pid != GProcessId)
98+
+ {
99+
+ GFirstSem = 0;
100+
+ used_sems = used_semids = max_semid = 0;
101+
+ sem_seq = 0;
102+
+ GProcessId = pid;
103+
+ }
104+
+ }
105+
+
106+
/************************************************************************/
107+
/* Demande d'acces a la zone partagee de gestion des semaphores */
108+
/************************************************************************/
109+
***************
110+
*** 77,82 ****
111+
--- 92,98 ----
112+
{
113+
int LRet ;
114+
115+
+ init_globals();
116+
if( GFirstSem == 0 )
117+
{
118+
if( IsGSemSemExist() )
119+
***************
120+
*** 187,193 ****
121+
{
122+
CloseHandle ( LHandle ) ;
123+
}
124+
! LHandle = CreateSemaphore(NULL, 0, 0x7FFFFFFF, LBuff) ;
125+
if( LHandle == NULL )
126+
{
127+
printf( "Creation de Semaphore \"Sem\" impossible\n" ) ;
128+
--- 203,209 ----
129+
{
130+
CloseHandle ( LHandle ) ;
131+
}
132+
! LHandle = CreateSemaphore(NULL, 0, 1, LBuff) ;
133+
if( LHandle == NULL )
134+
{
135+
printf( "Creation de Semaphore \"Sem\" impossible\n" ) ;
136+
***************
137+
*** 357,371 ****
138+
debug_printf("do_semop : return -EACCES\n");
139+
CYGWIN32_IPCNT_RETURN (-EACCES) ;
140+
}
141+
! ReleaseSemaphore(LHandle, sop->sem_op, &LVal) ;
142+
! shareadrsem->current_nb[id].current_nb[sop->sem_num] +=
143+
! sop->sem_op ;
144+
sem_deconnect() ;
145+
} else {
146+
if( sop->sem_flg == IPC_NOWAIT )
147+
{
148+
! LRet = WaitForSingleObject(LHandle, 0) ;
149+
! if( LRet == WAIT_TIMEOUT )
150+
{
151+
debug_printf("do_semop : return -EAGAIN\n");
152+
CYGWIN32_IPCNT_RETURN (-EAGAIN) ;
153+
--- 373,386 ----
154+
debug_printf("do_semop : return -EACCES\n");
155+
CYGWIN32_IPCNT_RETURN (-EACCES) ;
156+
}
157+
! shareadrsem->current_nb[id].current_nb[sop->sem_num] +=
158+
! sop->sem_op ;
159+
sem_deconnect() ;
160+
+ ReleaseSemaphore(LHandle, 1 , &LVal) ;
161+
} else {
162+
if( sop->sem_flg == IPC_NOWAIT )
163+
{
164+
! if( sop->sem_op + shareadrsem->current_nb[id].current_nb[sop->sem_num] <0 )
165+
{
166+
debug_printf("do_semop : return -EAGAIN\n");
167+
CYGWIN32_IPCNT_RETURN (-EAGAIN) ;
168+
***************
169+
*** 375,390 ****
170+
debug_printf("do_semop : return -EACCES\n");
171+
CYGWIN32_IPCNT_RETURN (-EACCES) ;
172+
}
173+
! shareadrsem->current_nb[id].current_nb[sop->sem_num] -= 1 ;
174+
sem_deconnect() ;
175+
} else {
176+
! LRet = WaitForSingleObject(LHandle, INFINITE) ;
177+
if (sem_connect() == 0)
178+
{
179+
debug_printf("do_semop : return -EACCES\n");
180+
CYGWIN32_IPCNT_RETURN (-EACCES) ;
181+
}
182+
! shareadrsem->current_nb[id].current_nb[sop->sem_num] -= 1 ;
183+
sem_deconnect() ;
184+
}
185+
}
186+
--- 390,407 ----
187+
debug_printf("do_semop : return -EACCES\n");
188+
CYGWIN32_IPCNT_RETURN (-EACCES) ;
189+
}
190+
! shareadrsem->current_nb[id].current_nb[sop->sem_num] += sop->sem_op;
191+
sem_deconnect() ;
192+
} else {
193+
! while(sop->sem_op + shareadrsem->current_nb[id].current_nb[sop->sem_num] <0)
194+
! LRet = WaitForSingleObject(LHandle, INFINITE) ;
195+
!
196+
if (sem_connect() == 0)
197+
{
198+
debug_printf("do_semop : return -EACCES\n");
199+
CYGWIN32_IPCNT_RETURN (-EACCES) ;
200+
}
201+
! shareadrsem->current_nb[id].current_nb[sop->sem_num] += sop->sem_op ;
202+
sem_deconnect() ;
203+
}
204+
}
205+
***************
206+
*** 435,441 ****
207+
char LBuff[100] ;
208+
HANDLE LHandle ;
209+
long LPrevious ;
210+
- int LIndex;
211+
212+
debug_printf("semctl : semid=%X semnum=%X cmd=0x%02X arg=%p\n",semid,semnum,cmd,arg);
213+
if (semid < 0 || semnum < 0 || cmd < 0)
214+
--- 452,457 ----
215+
***************
216+
*** 568,589 ****
217+
if( LHandle != NULL )
218+
{
219+
if( arg.val > shareadrsem->current_nb[id].current_nb[semnum] )
220+
! {
221+
! ReleaseSemaphore(LHandle,
222+
! arg.val-shareadrsem->current_nb[id].current_nb[semnum],
223+
! &LPrevious) ;
224+
! }
225+
! else if (arg.val <
226+
! shareadrsem->current_nb[id].current_nb[semnum] )
227+
! {
228+
! for( LIndex = arg.val;
229+
! LIndex < shareadrsem->current_nb[id].current_nb[semnum];
230+
! LIndex++ )
231+
! {
232+
! WaitForSingleObject(LHandle, 0) ;
233+
! }
234+
! }
235+
! shareadrsem->current_nb[id].current_nb[semnum] = arg.val ;
236+
}
237+
debug_printf("semctl : SETVAL : return 0\n");
238+
CYGWIN32_IPCNT_RETURN_DECONNECT (0);
239+
--- 584,591 ----
240+
if( LHandle != NULL )
241+
{
242+
if( arg.val > shareadrsem->current_nb[id].current_nb[semnum] )
243+
! ReleaseSemaphore(LHandle,1,&LPrevious) ;
244+
! shareadrsem->current_nb[id].current_nb[semnum] = arg.val ;
245+
}
246+
debug_printf("semctl : SETVAL : return 0\n");
247+
CYGWIN32_IPCNT_RETURN_DECONNECT (0);
248+
*** ./shm.c.orig Fri Sep 17 12:46:24 1999
249+
--- ./shm.c Fri Sep 17 12:47:11 1999
250+
***************
251+
*** 59,64 ****
252+
--- 59,81 ----
253+
static int GFirstShm = 0; /*PCPC*/
254+
static int GFdShm ; /*PCPC*/
255+
256+
+ /*****************************************/
257+
+ /* Initialization of static variables */
258+
+ /*****************************************/
259+
+ static pid_t GProcessId = 0;
260+
+ static void init_globals(void)
261+
+ {
262+
+ pid_t pid;
263+
+
264+
+ if (pid=getpid(), pid != GProcessId)
265+
+ {
266+
+ GFirstShm = 0;
267+
+ shm_rss = shm_swp = max_shmid = 0;
268+
+ shm_seq = 0;
269+
+ GProcessId = pid;
270+
+ }
271+
+ }
272+
+
273+
/************************************************************************/
274+
/* Demande d'acces a la zone partagee de gestion des shm */
275+
/************************************************************************/
276+
***************
277+
*** 82,87 ****
278+
--- 99,105 ----
279+
{
280+
int LRet ;
281+
282+
+ init_globals();
283+
if( GFirstShm == 0 )
284+
{
285+
if( IsGSemShmExist() )

0 commit comments

Comments
 (0)
0