Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit109d7af

Browse files
committed
Fix linking problem when enabling thread safety on Darwin: uninitialized
global variables are problematic on this platform. Simplest solutionseems to be to initialize pthread key variable to 0. Also, rename thisvariable and check_sigpipe_handler to something involving "pq" toavoid gratuitous pollution of application namespace.
1 parent8b82a70 commit109d7af

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.279 2004/08/11 18:06:01 tgl Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.280 2004/08/17 04:24:23 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -886,7 +886,7 @@ connectDBStart(PGconn *conn)
886886
staticpthread_once_tcheck_sigpipe_once=PTHREAD_ONCE_INIT;
887887

888888
/* Check only on first connection request */
889-
pthread_once(&check_sigpipe_once,check_sigpipe_handler);
889+
pthread_once(&check_sigpipe_once,pq_check_sigpipe_handler);
890890
#endif
891891
#endif
892892

‎src/interfaces/libpq/fe-print.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* didn't really belong there.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.51 2004/04/19 17:42:59 momjian Exp $
13+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.52 2004/08/17 04:24:23 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -188,7 +188,7 @@ PQprint(FILE *fout,
188188
{
189189
usePipe=1;
190190
#ifdefENABLE_THREAD_SAFETY
191-
pthread_setspecific(thread_in_send,"t");
191+
pthread_setspecific(pq_thread_in_send,"t");
192192
#else
193193
#ifndefWIN32
194194
oldsigpipehandler=pqsignal(SIGPIPE,SIG_IGN);
@@ -310,7 +310,7 @@ PQprint(FILE *fout,
310310
pclose(fout);
311311
#endif
312312
#ifdefENABLE_THREAD_SAFETY
313-
pthread_setspecific(thread_in_send,"f");
313+
pthread_setspecific(pq_thread_in_send,"f");
314314
#else
315315
#ifndefWIN32
316316
pqsignal(SIGPIPE,oldsigpipehandler);

‎src/interfaces/libpq/fe-secure.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.45 2004/07/12 14:23:28 momjian Exp $
14+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.46 2004/08/17 04:24:23 tgl Exp $
1515
*
1616
* NOTES
1717
* The client *requires* a valid server certificate. Since
@@ -152,7 +152,7 @@ static SSL_CTX *SSL_context = NULL;
152152

153153
#ifdefENABLE_THREAD_SAFETY
154154
staticvoidsigpipe_handler_ignore_send(intsigno);
155-
pthread_key_tthread_in_send;
155+
pthread_key_tpq_thread_in_send=0;
156156
#endif
157157

158158
/* ------------------------------------------------------------ */
@@ -367,7 +367,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
367367
ssize_tn;
368368

369369
#ifdefENABLE_THREAD_SAFETY
370-
pthread_setspecific(thread_in_send,"t");
370+
pthread_setspecific(pq_thread_in_send,"t");
371371
#else
372372
#ifndefWIN32
373373
pqsigfuncoldsighandler=pqsignal(SIGPIPE,SIG_IGN);
@@ -435,7 +435,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
435435
n=send(conn->sock,ptr,len,0);
436436

437437
#ifdefENABLE_THREAD_SAFETY
438-
pthread_setspecific(thread_in_send,"f");
438+
pthread_setspecific(pq_thread_in_send,"f");
439439
#else
440440
#ifndefWIN32
441441
pqsignal(SIGPIPE,oldsighandler);
@@ -1188,7 +1188,7 @@ PQgetssl(PGconn *conn)
11881188
*Check SIGPIPE handler and perhaps install our own.
11891189
*/
11901190
void
1191-
check_sigpipe_handler(void)
1191+
pq_check_sigpipe_handler(void)
11921192
{
11931193
pqsigfuncpipehandler;
11941194

@@ -1204,7 +1204,7 @@ check_sigpipe_handler(void)
12041204
*Create key first because the signal handler might be called
12051205
*right after being installed.
12061206
*/
1207-
pthread_key_create(&thread_in_send,NULL);
1207+
pthread_key_create(&pq_thread_in_send,NULL);
12081208
pqsignal(SIGPIPE,sigpipe_handler_ignore_send);
12091209
}
12101210
}
@@ -1236,8 +1236,8 @@ pqbool
12361236
PQinSend(void)
12371237
{
12381238
#ifdefENABLE_THREAD_SAFETY
1239-
return (pthread_getspecific(thread_in_send)/* has it been set? */&&
1240-
*(char*)pthread_getspecific(thread_in_send)=='t') ? true : false;
1239+
return (pthread_getspecific(pq_thread_in_send)/* has it been set? */&&
1240+
*(char*)pthread_getspecific(pq_thread_in_send)=='t') ? true : false;
12411241
#else
12421242
/*
12431243
*No threading: our code ignores SIGPIPE around send().

‎src/interfaces/libpq/libpq-int.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.88 2004/05/31 18:42:40 tgl Exp $
15+
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.89 2004/08/17 04:24:23 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -456,8 +456,8 @@ extern void pqsecure_close(PGconn *);
456456
externssize_tpqsecure_read(PGconn*,void*ptr,size_tlen);
457457
externssize_tpqsecure_write(PGconn*,constvoid*ptr,size_tlen);
458458
#ifdefENABLE_THREAD_SAFETY
459-
externvoidcheck_sigpipe_handler(void);
460-
externpthread_key_tthread_in_send;
459+
externvoidpq_check_sigpipe_handler(void);
460+
externpthread_key_tpq_thread_in_send;
461461
#endif
462462

463463
#ifdefUSE_SSL

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp