Commit Graph

7943 Commits

Author SHA1 Message Date
davidxu
680ab8905d If syscall failed, restore old sigaction and return error to thread. 2003-09-25 06:23:40 +00:00
davidxu
325b5ebdea As comments in _mutex_lock_backout state, only current thread
can clear the pointer to mutex, not the thread doing mutex
handoff. Because _mutex_lock_backout does not hold scheduler
lock while testing THR_FLAGS_IN_SYNCQ and then reading mutex
pointer, it is possible mutex owner begin to unlock and
handoff the mutex to the current thread, and mutex pointer
will be cleared to NULL before current thread reading it, so
current thread will end up with deferencing a NULL pointer,
Fix the race by making mutex waiters to clear their mutex pointers.
While I am here, also save inherited priority in mutex for
PTHREAD_PRIO_INERIT mutex in mutex_trylock_common just like what
we did in mutex_lock_common.
2003-09-24 12:52:57 +00:00
marcus
1598bfd0f5 Grrr...add the Skinny alias code forgotten in the last commit. 2003-09-23 07:42:33 +00:00
marcus
429e15dea7 Add Cisco Skinny Station protocol support to libalias, natd, and ppp.
Skinny is the protocol used by Cisco IP phones to talk to Cisco Call
Managers.  With this code, one can use a Cisco IP phone behind a FreeBSD
NAT gateway.

Currently, having the Call Manager behind the NAT gateway is not supported.
More information on enabling Skinny support in libalias, natd, and ppp
can be found in those applications' manpages.

PR:		55843
Reviewed by:	ru
Approved by:	ru
MFC after:	30 days
2003-09-23 07:41:55 +00:00
davidxu
4fb7f47253 Free thread name memory if there is. 2003-09-23 04:02:23 +00:00
davidxu
dfbbf3ec80 Save and restore timeout field for signal frame just like what we did
for interrupted field.
Also in _thr_sig_handler, retrieve current signal mask from kernel not
from ucp, the later is pre-unioned mask, not current signal mask.
2003-09-22 14:40:36 +00:00
davidxu
a70d9fb2c2 Fix FPU state restoring bug by jumping to right position. 2003-09-22 14:34:02 +00:00
davidxu
bb5ac5c379 Print waitset correctly. 2003-09-22 00:40:23 +00:00
marcel
57ccbd6240 Make KSE_STACKSIZE machine dependent by moving it from thr_kern.c to
pthread_md.h. This commit only moves the definition; it does not
change it for any of the platforms. This more easily allows 64-bit
architectures (in particular) to pick a slightly larger stack size.
2003-09-19 23:28:13 +00:00
marcel
c61eebe4d0 _ia64_break_setcontext() now takes a mcontext_t. While here, define
THR_SETCONTEXT as PANIC(). The THR_SETCONTEXT macro is currently not
used, which means that the definition we had could be wrong, overly
pessimistic or unknowingly right. I don't like the odds...

The new _ia64_break_setcontext() and corresponding kernel fixes make
KSE mostly usable. There's still a case where we don't properly
restore a context and end up with a NaT consumption fault (typically
an indication for not handling NaT collection points correctly),
but at least now mutex_d works...
2003-09-19 23:00:28 +00:00
marcel
6f2a7c4c37 Stop using the setcontext() syscall to restore an async context.
Instead use the break instruction with an immediate specially
created for us.
2003-09-19 22:54:05 +00:00
des
c5c27920e0 Ignore ECHILD from waitpid(2) (our child may have been reaped by the
calling process's SIGCHLD handler)

PR:		bin/45669
2003-09-19 11:33:03 +00:00
davidxu
c2bda27825 pthread api should return error code in return value, not in errno. 2003-09-18 12:19:28 +00:00
davidxu
8a841ec2e7 Fix a typo. Also turn on PTHREAD_SCOPE_SYSTEM after fork(). 2003-09-16 02:03:39 +00:00
deischen
4d83fbebd8 Remove a comment that questioned why the size of the FPU
state for amd64 was twice as large as necessary.  Peter
recently fixed this, so the comment no longer applies.

Also, since the size of struct mcontext changed, adjust
the threads library version of get&set context to match.

FYI, any change layout/size change to any arch's struct
mcontext will likely need some minor changes in libpthread.
2003-09-16 00:00:53 +00:00
fenner
2eb9e797c4 From OpenBSD:
always widen the imputed netmask if it is narrower than the specified octets.
fixes a strange behaviour where inet_net_pton would always return 4 (bits)
for multicast addresses no matter how many octets were specified.

negotiated with Paul Vixie, original author of this function.

PR:		standards/53151
Submitted by:	Max Laier <max@love2party.net>
Optained from:	OpenBSD
2003-09-15 23:38:06 +00:00
ume
e4b69e5194 Our getaddrinfo() and getnameinfo() are thread-safe but
some limitation.

Reported by:	Marc G. Fournier <scrappy@hub.org>
2003-09-15 04:52:15 +00:00
davidxu
5b6e094e88 Fix bogus comment and assign sigmask in critical region, use
SIG_CANTMASK to remove unmaskable signal masks.
2003-09-15 00:08:48 +00:00
davidxu
f0d690ca3b Fix a bogus comment, sigmask must be maintained correctly,
it will be inherited in pthread_create.
2003-09-15 00:06:46 +00:00
davidxu
88517f2bfb 1. Allocating and freeing lock related resource in _thr_alloc and _thr_free
to avoid potential memory leak, also fix a bug in pthread_create, contention
   scope should be inherited when PTHREAD_INHERIT_SCHED is set, and also check
   right field for PTHREAD_INHERIT_SCHED, scheduling inherit flag is in sched_inherit.
2. Execute hooks registered by atexit() on thread stack but not on scheduler
   stack.
3. Simplify some code in _kse_single_thread by calling xxx_destroy functions.

Reviewed by: deischen
2003-09-14 22:52:16 +00:00
davidxu
6bb97514a6 When invoking an old style signal handler, use true traditional BSD style to
invoke signal handler.

Reviewed by: deischen
2003-09-14 22:42:39 +00:00
davidxu
3a38b0df30 Respect POSIX specification, a value return from pthread_attr_getguardsize
should be a value past to pthread_attr_setguardsize, not a rounded up value.
Also fix a stack size matching bug in thr_stack.c, now stack matching code
uses number of pages but not bytes length to match stack size, so for example,
size 512 bytes and size 513 bytes should both match 1 page stack size.

Reviewed by: deischen
2003-09-14 22:39:44 +00:00
davidxu
2733205df0 Avoid garbage bits in c_flags by direct assigning value.
Reviewed by: deischen
2003-09-14 22:33:32 +00:00
davidxu
45e25ef552 If user is seting scope process flag, clear PTHREAD_SCOPE_SYSTEM bit
accordingly.

Reviewed by: deischen
2003-09-14 22:32:28 +00:00
davidxu
52da9a294e Check invalid parameter and return EINVAL.
Reviewed by: deischen
2003-09-14 22:28:13 +00:00
ru
f501f1b590 Get rid of duplicates. 2003-09-14 13:41:59 +00:00
ru
5f36712a74 mdoc(7): Fix common mistakes made in the SEE ALSO section. 2003-09-12 21:54:11 +00:00
ru
c581c0c568 mdoc(7): Properly mark C headers. 2003-09-10 19:24:35 +00:00
roberto
11fbeb6f7c Document the fact that send(2) can return EPIPE (like when a socket is not
connected).

PR:		docs/56683
Submitted by:	Chris S.J. Peron <maneo@bsdpro.com>
MFC after:	3 days
2003-09-10 19:19:49 +00:00
ru
cc428340fa Fixed -Wpointer-arith warning.
Submitted by:	Stefan Farfeleder
PR:		bin/56653
2003-09-09 23:50:57 +00:00
davidxu
a49f338da8 Original pthread_once code has memory leak if pthread_once_t is used in
a shared library or any other dyanmic allocated data block, once
pthread_once_t is initialized, a mutex is allocated, if we unload the
shared library or free those data block, then there is no way to deallocate
the mutex, result is memory leak.
To fix this problem, we don't use mutex field in pthread_once_t, instead,
we use its state field and an internal mutex and conditional variable in
libkse to do any synchronization, we introduce a third state IN_PROGRESS to
wait if another thread is already in invoking init_routine().
Also while I am here, make pthread_once() conformed to pthread cancellation
point specification.

Reviewed by: deischen
2003-09-09 22:38:12 +00:00
davidxu
fd097cd051 Add code to support pthread spin lock.
Reviewed by: deischen
2003-09-09 06:57:51 +00:00
ru
b8e742a388 mdoc(7): Use the new feature of the .In macro. 2003-09-08 19:57:22 +00:00
iedowse
36075ef78b In the !MNT_BYFSID case, return EINVAL from unmount(2) when the
specified directory is not found in the mount list. Before the
MNT_BYFSID changes, unmount(2) used to return ENOENT for a nonexistent
path and EINVAL for a non-mountpoint, but we can no longer distinguish
between these cases. Of the two error codes, EINVAL was more likely
to occur in practice, and it was the only one of the two that was
documented.

Update the manual page to match the current behaviour.

Suggested by:	tjr
Reviewed by:	tjr
2003-09-08 16:23:21 +00:00
davidxu
06e4314d5e Add small piece of code to support pthread_rwlock_timedrdlock and
pthread_rwlock_timedrwlock.
2003-09-06 00:07:52 +00:00
kan
9fe3b42d97 The caller is expected to set up PIC register corectly before
jumping to .cerror. This means .cerror has to be present in the
same module with its consumers, or bad things will happen.
2003-09-05 18:08:19 +00:00
roam
5c08296b92 Clarify that the second argument to accept() may be a null pointer if
no peer address information is desired.

PR:		56044
Submitted by:	Felix Opatz <felix@zotteljedi.de> and
		Bernd Luevelsmeyer <bdluevel@heitec.net>
MFC after:	1 month
2003-09-05 15:41:52 +00:00
tjr
79fc736b7a Remove an unused and incorrect prototype for _none_init(). 2003-09-05 09:01:31 +00:00
simon
a39242b93f Move a sentence about the terminating \0 from the RETURN VALUES section
(where it didn't really belong), to the DESCRIPTION section.

English advice:	ceri
Requested by:	das
MFC after:	4 weeks
2003-09-04 20:36:54 +00:00
davidxu
f914f8856f Add code to support barrier synchronous object and implement
pthread_mutex_timedlock().

Reviewed by: deischen
2003-09-04 14:06:43 +00:00
davidxu
6a27d7fc87 Remove repeated macro THR_IN_CONDQ. 2003-09-04 07:46:26 +00:00
davidxu
e677b7320c Allow hooks registered by atexit() to run with current thread pointer set,
without this change, my atexit test dumps core.
2003-09-04 05:24:53 +00:00
peter
f8ae9fee59 Sigh. I can't win anything. Use addq rather than addl with %rsp. 2003-09-04 00:31:45 +00:00
peter
de34c3b774 Apply same basic fix for getcontext(2) as for i386. Store the return
value for getcontext() in a preserved register rather than on the stack.
The second time around, the stack value would likely have changed so we
can't depend on it for the return value.
2003-09-04 00:29:12 +00:00
peter
8113c1d20c Fix some minor whitespace botches 2003-09-04 00:26:40 +00:00
peter
73d537652a Make getcontext(2) work on i386. It needs a small wrapper in libc
otherwise the return from the syscall stub for getcontext will pop off
the return value for the caller to the getcontext stub and it will appear
as though the setcontext() syscall returned instead of the getcontext().
The same bug exists on amd64, a fix is coming there too.

The bug can be demonstrated with this test code fragment:
main()
{
        ucontext_t top;

        if (getcontext(&top) == 0) {
                write(2, "PING!\n", 6);
                /* Cause a return value of 1 from getcontext this time */
                top.uc_mcontext.mc_eax = 1;
                setcontext(&top);
                err(1, "setcontext() returned");
        }
        write(2, "PONG!\n", 6);
        _exit(0);
}
2003-09-04 00:20:40 +00:00
deischen
8271ec1da3 Don't assume sizeof(long) = sizeof(int) on x86; use int
instead of long types for low-level locks.

Add prototypes for some internal libc functions that are
wrapped by the library as cancellation points.

Add memory barriers to alpha atomic swap functions (submitted
by davidxu).

Requested by:	bde
2003-09-03 17:56:26 +00:00
davidxu
6a2d053fbe Move kse_wakeup_multi call to just before KSE_SCHED_UNLOCK.
Tested on: SMP
2003-09-03 00:21:10 +00:00
kan
4c3d911e6a Rethink the way thr_libc.So is generated. Relying on GCC to extract
only needed symbols from libc_pic is not working on sparc64.

Requested by: jake
2003-09-02 19:37:11 +00:00
dds
5039a5114a Fix/add errno return values to match the NFS client implementation and
better represent failures of special files accessed over NFS.

Approved by:	schweikh (mentor)
Reviewed by:	bde (as a description)
MFC after:	6 weeks
2003-09-02 16:50:17 +00:00