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

Commit72ed916

Browse files
committed
Add errno value for thread *_r function call buffer too small. Improve
thread comments.
1 parent24d41a9 commit72ed916

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎src/port/thread.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
99
*
10-
* $Id: thread.c,v 1.7 2003/09/13 14:49:51 momjian Exp $
10+
* $Id: thread.c,v 1.8 2003/09/15 02:30:29 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -17,6 +17,7 @@
1717
#include<pthread.h>
1818
#include<sys/types.h>
1919
#include<pwd.h>
20+
#include<errno.h>
2021

2122
/*
2223
*Threading sometimes requires specially-named versions of functions
@@ -48,6 +49,12 @@
4849
*use *_r functions if they exist (configure test)
4950
*do our own locking and copying of non-threadsafe functions
5051
*
52+
*The disadvantage of the last option is not the thread overhead but
53+
*the fact that all function calls are serialized, and with gethostbyname()
54+
*requiring a DNS lookup, that could be slow.
55+
*
56+
*One thread-safe solution for gethostbyname() might be to use getaddrinfo().
57+
*
5158
*Compile and run src/tools/test_thread_funcs.c to see if your operating
5259
*system has thread-safe non-*_r functions.
5360
*/
@@ -143,7 +150,10 @@ pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer,
143150
*result=resultbuf;
144151
}
145152
else
153+
{
146154
*result=NULL;
155+
errno=ERANGE;
156+
}
147157

148158
pthread_mutex_unlock(&getpwuid_lock);
149159
#endif
@@ -239,7 +249,10 @@ pqGethostbyname(const char *name,
239249
*result=resultbuf;
240250
}
241251
else
252+
{
242253
*result=NULL;
254+
errno=ERANGE;
255+
}
243256
}
244257
#endif
245258

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp