Commit graph

7688 commits

Author SHA1 Message Date
Matthew N. Dodd 913111f124 Correct an apparent typo.
PR:		 bin/53515
Submitted by:	 Lukas Ertl <l.ertl@univie.ac.at>
Approved by:	 jmallett
2003-06-19 22:12:54 +00:00
Kris Kennaway 97cbd1c728 Remove bogus non-reentrant "temporary" implementation of gethostbyaddr_r()
that has been here for 6 years and 9 months.

Reviewed by:	deischen
MFC After:	1 week
2003-06-19 07:57:11 +00:00
Philippe Charnier b160a51e51 The .Fn function 2003-06-18 19:43:17 +00:00
Hajimu UMEMOTO ed40ddd9dc Add IPv6 related attributes defined in RFC3162.
MFC after:	1 week
2003-06-18 17:29:15 +00:00
Ruslan Ermilov 19c2ee9e5f Make the execle() synopsis look (again) like a normal C prototype.
Also fixed the rest of ell (list) functions prototypes to include
a (commented out) terminating null pointer.

Pointed out by:	bde
Obtained from:	POSIX.1-2001
Glanced at by:	imp
2003-06-18 15:24:21 +00:00
David Xu eb90369fa6 Don't lock scheduler lock twice. 2003-06-18 06:08:03 +00:00
Maxim Sobolev e2ff474cac Xref policy: exit(2) -> _exit(2). 2003-06-17 09:36:47 +00:00
Poul-Henning Kamp bbaba031a5 Fix the execle(3) synopsis to include the environment pointer.
Confused:	anordby
2003-06-17 08:57:37 +00:00
Doug Barton 605d07fcea Fix the #include part of the SYNOPSIS for heap.3
PR:		bin/45269
Submitted by:	Slaven Rezic <slaven.rezic@berlin.de>
2003-06-17 08:43:19 +00:00
Martin Blapp b77aeb1292 Kill prototype for __msgwrite too. It is not needed anymore. 2003-06-15 10:55:39 +00:00
Martin Blapp dd01398df6 Fix the master yppasswd routines, so they really work
for root on ypmaster. yppasswd_local() did use YPPASSWDPROG
instead of MASTER_YPPASSWDPROG, and the domain was not set,
resulting in a coredump during xdr-encode.

Reviewed by:	des
2003-06-15 10:37:22 +00:00
Martin Blapp ec01fc4f14 Fix the master yppasswd routines, so they really work
for root on ypmaster. Fix ypclnt_havepasswdd() to work
for AF_LOCAL connections.

Reviewed by:	des
2003-06-15 10:36:53 +00:00
Martin Blapp ce9bc43cb3 Replace the old SCM_CREDS cred procedures. They can now be
replaced just fine with getpeereid() and the whole code
gets a lot simpler. We don't break the ABI, since all server
programms use __rpc_get_local_uid(), and we just change library
internals.

Reviewed by:	des
2003-06-15 10:32:01 +00:00
David Xu d8406ada91 P_THREADED was renamed to P_SA, follow up. 2003-06-15 03:42:04 +00:00
David E. O'Brien 457946d9bd Remove MAINTAINER lines. 2003-06-14 19:32:52 +00:00
Mark Murray 0ebec5d3c8 Tidy up. Sort headers. 2003-06-14 18:42:37 +00:00
David E. O'Brien 5c784c8f4b Only use this with a non-GCC compiler. 2003-06-14 06:04:23 +00:00
Kenneth D. Merry 50a7fdaed8 Remove MAINTAINER= lines in the makefiles for camcontrol, iostat, libcam
and libdevstat, since the new way of doing things is to just list
maintainership in src/MAINTAINERS.

Also, remove duplicate entries in src/MAINTAINERS for those utilities.  I
already had entries for them.
2003-06-14 05:28:01 +00:00
Tom Rhodes 720f2e44a3 Document ENOSPC.
PR:		52612
Submitted by:	Marc Olzheim <marcolz@ilse.nl>
2003-06-13 22:41:12 +00:00
Peter Wemm 70de0c73a5 This is unusable on amd64. Remove it before it causes more confusion.
It is only possible to do this on an ABI that has a compulsory frame
pointer, which the amd64 ABI does not.  Thus, it is only possible to
implement this as a compiler builtin.
2003-06-13 21:56:30 +00:00
Ruslan Ermilov ada24e690c In the PKT_ALIAS_PROXY_ONLY mode, make sure to preserve the
original source IP address, as promised in the manual page.

Spotted by:	Vaclav Petricek
2003-06-13 21:54:01 +00:00
Ruslan Ermilov 9c88dc8855 Removed a couple of .Xo/.Xc that are leftovers of the "ninth-argument
limit" mdoc(7) atavism.
2003-06-13 21:39:22 +00:00
Ruslan Ermilov 7176089886 Clarify that original address and port when doing transparent proxying
are _destination_ address and port.
2003-06-13 21:36:24 +00:00
Ruslan Ermilov 61de149d30 Added myself to the AUTHORS section. 2003-06-13 21:32:01 +00:00
Tim J. Robbins a5e2489d03 Mark libxpg4 as OBSOLETE_IN_6: it has been empty since its contents
were merged into libc in 4.5-RELEASE.
2003-06-13 07:21:37 +00:00
Tim J. Robbins 77156cb782 Mark the following interfaces as OBSOLETE_IN_6:
fgetrune(), fputrune(), fungetrune(), mbrune(), mbrrune(), mbmb(),
    setinvalidrune(), UTF2 encoding method.
These have been marked as being deprecated in their manual pages since 5.0,
and their use causes a linker warning.
2003-06-13 07:13:54 +00:00
Jordan K. Hubbard 3dfdc427f1 Fixes to locale code to properly use indirect pointers in order to prevent
memory leaks (fixes bugs earlier purported to be fixed).
Submitted by:	Ed Moy <emoy@apple.com>
Obtained from:	Apple Computer, Inc.
MFC after:	2 weeks
2003-06-13 00:14:07 +00:00
David E. O'Brien 11f0fab4fa Use C99 compatible ASM statements.
(untested, but existing state breaks
http://triangle.rtp.freebsd.org/~des/tinderbox-CURRENT-amd64-amd64.brief)
2003-06-10 21:17:55 +00:00
Tom Rhodes 0315901c7c Add an EXAMPLES section.
PR:		43899
Reviewed by:	des, ru
2003-06-10 20:41:18 +00:00
Juli Mallett dfa13bbf27 Various cleanups of careless mistakes/omissions.
PR:		53149
Submitted by:	Lukas Ertl <l.ertl@univie.ac.at>
2003-06-10 18:36:16 +00:00
Juli Mallett 27fd747882 Left out the critical part of my "public domain" template, a notice saying
that this file is (these files are) in the public domain.

PR:		53149
2003-06-10 18:24:40 +00:00
Andrey A. Chernov 0c7fbc6c40 Remove transition period hack 2003-06-10 01:26:04 +00:00
Mike Makonnen 05e948d996 _thread_printf() is only used for debugging or in cases where something's
screwed beyond all help, so it can just skip the pthreads wrapper
for write(2) and call directly into it.
2003-06-09 17:58:15 +00:00
Alexander Leidinger f970961773 Sanity check fd before using it as an array index.
Noticed by:	ted@NLnetLabs.nl (Ted Lindgreen)
Approved by:	ru
2003-06-09 16:45:37 +00:00
John Baldwin dff6f51034 Remove stale reference to the deprecated USER_LDT option. The associated
code is always compiled into the kernel now.

Submitted by:	Hubert Tournier <hubert@frbsd.org>
PR:		docs/53068
2003-06-09 11:46:22 +00:00
Juli Mallett e78ea9f724 Commit rudimentary libufs manual pages, except for that for
getino(3)/putino(3), inode.c has been reworked in Perforce to the point
where a manual page may not be accurate.  Certainly putino(3) has not
even been merged back yet.

These will need a lot of improvement for most applications, but they
document the API enough to get someone on their feet, most likely.  The
best documentation still exists in the form of libufs(3) consumers in the
base system.
2003-06-09 09:59:11 +00:00
Juli Mallett b52f85e743 Remove ufs_disk_ctor and ufs_disk_dtor, they never came to fruition. I do
not know of any software using them, and there is no "published API" for
libufs, as it were.
2003-06-09 09:47:38 +00:00
Juli Mallett 1081253fa0 Reduce diffs with code in Perforce:
Parenthesise return values.
2003-06-09 09:32:29 +00:00
Ceri Davies 6efa541f23 Correct a typo.
MFC After:	2 days
2003-06-08 19:41:58 +00:00
Daniel Eischen 690f13f3c3 After selecting a thread to handle a signal and taking
its scheduling lock, make sure that the thread still has
the signal unmasked.

Make a debug statement conditional on debugging being
enabled.
2003-06-08 17:37:21 +00:00
Daniel Eischen f91de797ce Insert threads at the end of the free thread list so that
the chance of getting the same thread id when allocating a
new thread is reduced.  This won't work if the application
creates a new thread for every time a thread exits, but
we're still within the allowances of POSIX.
2003-06-08 17:35:11 +00:00
Daniel Eischen 4d6f145a3b Provide a reference to __sys_write. The implementation uses this when
debugging is enabled so the symbol needs to be resolved before rtld
locking is enabled.  I may not really know what I'm talking about,
but it works.

Submitted by:	kan
2003-06-08 17:29:32 +00:00
Philippe Charnier 19677e1070 The .Fn function 2003-06-08 10:40:44 +00:00
Philippe Charnier 3c024cc85c The .Fn function 2003-06-08 10:34:00 +00:00
Philippe Charnier e4f2c10b4c The .Fn function 2003-06-08 10:20:32 +00:00
Philippe Charnier 82f7b9cd41 Add section number with .Xr. .Xr -> .Vt changes. 2003-06-08 10:17:24 +00:00
Philippe Charnier ab165955de The .Fn function 2003-06-08 10:13:50 +00:00
Philippe Charnier 7712c6658b .Xr p1003_1b moved to .St -p1003.1b-93 2003-06-08 10:11:13 +00:00
Philippe Charnier fe71ab1cf4 .Xr -> .Lb for librairy. There is no manual page corresponding to .Xr. 2003-06-08 10:07:14 +00:00
Philippe Charnier 0d511e328f Add or correct section number in .Xr. Use .Vt or .Fn
instead of .Xr when needed
2003-06-08 10:01:52 +00:00
Philippe Charnier 9703a107f2 The .Fn function 2003-06-08 09:53:08 +00:00
Warner Losh cedfd4f63f Don't force -L/usr/lib. This is incorrect because we should not be
looking at the host environment for anything.  This breaks building
-CURRENT on 4.x as well.

Submitted by: kan@
2003-06-08 03:58:20 +00:00
Scott Long 4e89f2d88f Sanity check the list obtained from the kern.disks sysctl so that Disk_Names()
doesn't get fooled into returning a bogus list.  This should fix sysinstall
from segfaulting when no disk devices are present.
2003-06-07 20:02:56 +00:00
Jun Kuriyama 3a624f5e23 Use
cat ${.ALLSRC} > ${.TARGET}
rather than
	ln -sf ${.ALLSRC} ${.TARGET}
not to depends on absolute-path of symbolic links.

Commented by:  marcel, obrien, bde
2003-06-06 13:46:55 +00:00
Poul-Henning Kamp c6dd496cd9 Recognize the magic NODEV value.
Format other unknown devices consistently in hex.
2003-06-05 21:55:57 +00:00
Mark Murray f2017a1921 Rename local variables to not mask global names of same name. This
fixes lots of lint(1) warnings.
2003-06-05 13:17:32 +00:00
Marcel Moolenaar fee5c3f1f8 Make this compile without warnings on 64-bit architectures:
Don't cast thread_self() to int. Cast to uintptr_t. Pull in the
predefined printf format from <inttypes.h>
2003-06-04 20:38:54 +00:00
Marcel Moolenaar f10382ac87 Make this compile without warnings on 64-bit architectures:
In recurse(), cast the pointer difference to int to match the format.
The difference is expected to fit in an int.
2003-06-04 20:36:08 +00:00
Mark Murray 2f8e800c38 Drop stale MAINTAINER bit. 2003-06-04 16:01:37 +00:00
David Xu a05fa0abea Only init _thread_sigact once, needn't init it again after a fork().
Obtained from: deischen
2003-06-04 12:40:21 +00:00
David Xu cd0a0c267b Despite whether threaded mode is turned on, always save thread's
signal mask.
2003-06-04 12:38:21 +00:00
Bruce Evans c749b4f6dd Removed garbage:
- -elf in CFLAGS had no effect except to reduce portability.
- -elf in LDFLAGS had even less effect, since LDFLAGS is not used.
- -Wall in CFLAGS had no effect except to reduce portability and break
  overriding of WARNS, since the setting of WARNS implies -Wall.
2003-06-04 11:21:18 +00:00
Mike Makonnen 4dee39fea0 Make C applications statically compiled with libthr work. Previously,
an application compiled -static with libthr would dump core in
malloc(3) because the stub thread initialization routine in libc would
be used instead of the libthr supplied one.
2003-06-04 08:23:05 +00:00
Mike Makonnen f833c84a8f If the library is not able to create a thread because resources
don't allow it at the moment, the correct thing to do is try again.
Otherwise, libthr would fail this test because it doesn't allow
an unlimited number of concurrent threads per application.
2003-06-04 08:16:32 +00:00
Robert Watson 44f5ca2f16 Document the new explicit listing API for extended attributes; note
that the old API (passing "" as the attribute name to the _get_
interface) is now deprecated (and was probably a bad idea).

Pointed out by:	Dominic Giampaolo <dbg@apple.com>
Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
2003-06-04 04:00:26 +00:00
David Xu e84a8d0d65 KMF_DONE is now in /sys/sys/kse.h, no longer need to define it here. 2003-06-04 03:22:59 +00:00
Hiten Pandya 8e9a665fde Document that kldload(2) can also return EEXIST.
Approved by: des (mentor)
2003-06-03 12:29:34 +00:00
Mike Makonnen b9662ddd18 Teach recent changes in the umtx structure in the kernel to the libthr
initialiazer.

Found by:	tinderbox
2003-06-03 09:31:33 +00:00
David Xu a4c69f224b Free memory of internal low level lock when mutex and condition variable
are destroyed.

Submitted by: tegge
2003-06-03 02:21:01 +00:00
Peter Wemm 3191d840e0 Cosmetic; record offsets used within jmpbuf 2003-06-02 22:37:53 +00:00
Peter Wemm 19816dec92 Update for amd64 after repocopy from i386/ 2003-06-02 22:30:59 +00:00
Peter Wemm 3aefe09423 Port libc_r to amd64, and turn it back on for amd64. It passes all of
the same src/lib/libc_r/test/* tests that the other platforms pass.
2003-06-02 22:22:52 +00:00
Peter Wemm b8f8813c6e Fix sigsetjmp(). It helps if we do not try to save the old signal mask
to a random memory location.  Perl works a lot better with this.
2003-06-02 21:59:13 +00:00
Mark Murray d8e82636a4 Tidy the code up a fraction. Re-release with a 2-clause BSD license
with the kind permission of the author/copyright holder.

Thanks to:	phk
2003-06-02 21:43:14 +00:00
Mark Murray bf513f6958 Add a new hash type. This "NT-hash" is compatible with the password
hashing scheme used in Microsoft's NT machines. IT IS NOT SECURE!
DON'T USE IT! This is for the use of competent sysadmins only!

Submitted by:	Michael Bretterklieber
2003-06-02 19:29:27 +00:00
Mike Makonnen cff6c3cab1 Unwind the _giant_mutex from pthread_detach(). When detaching a joiner thread
it's important the correct lock order is observed: lock first the joined and
then the joiner.
2003-06-02 11:01:00 +00:00
Mike Makonnen 4384412030 Consolidate static_init() and static_init_private into one function.
The behaviour of this function is controlled by the argument: private.
2003-06-02 10:04:18 +00:00
David E. O'Brien a23e5f4d43 .S comments must be C comments, not ASM ones. 2003-06-02 02:32:56 +00:00
David E. O'Brien e683295e39 Use C99 compatible ASM statements. 2003-06-02 02:32:22 +00:00
Robert Watson 778f8875c7 Revert accidental change: don't change the thread library for testing to
libthr.  Oops, sorry about that.

Submitted by:	"Simon L. Nielsen" <simon@nitro.dk>
2003-06-02 00:21:41 +00:00
Marcel Moolenaar 75fa7db991 o Fix a cut-n-paste bug. We were clobbering rp with gp...
o  Make sure the arguments to ctx_wrapper() are loaded from the
   backing store by forcing an underflow. Do this by making all
   registers in the register frame local.
2003-06-02 00:16:39 +00:00
Ruslan Ermilov 234dfc904a A new API function PacketAliasRedirectDynamic() can be used
to mark a fully specified static link as dynamic; i.e. make
it a one-time link.
2003-06-01 23:15:00 +00:00
Robert Watson 0bbe770d6f Include string.h for memset(). 2003-06-01 23:03:49 +00:00
Ruslan Ermilov f1a529f3da Make the PacketAliasSetAddress() function call optional. If it
is not called, and no static rules match an outgoing packet, the
latter retains its source IP address.  This is in support of the
"static NAT only" mode.
2003-06-01 22:49:59 +00:00
Juli Mallett d7ea49283c Match style of source and headers.
Submitted by:	bde
2003-06-01 21:35:27 +00:00
Ruslan Ermilov 9be025500d Assorted mdoc(7) fixes. 2003-06-01 19:41:49 +00:00
Ruslan Ermilov 0e35e492fc Assorted mdoc(7) fixes. 2003-06-01 19:19:59 +00:00
Andrey A. Chernov 9d793e98ec Add GBK encoding
PR:             51504
Submitted by:   Statue <statue@freebsd.sinica.edu.tw>
2003-06-01 15:30:56 +00:00
Poul-Henning Kamp 7e02e189ae Add the part of the last commit which cvs appearantly didn't like
the first time.
2003-06-01 15:05:22 +00:00
Dag-Erling Smørgrav 2d2b70f60b Add openpam_readline(3). 2003-06-01 12:54:51 +00:00
Dag-Erling Smørgrav 008c1ace7b Retire pam_wheel(8) (which has been disconnected for quite a while) and
pam_ftp(8).
2003-06-01 11:50:35 +00:00
Poul-Henning Kamp b600adca79 Clarify the code a bit.
Submitted by:	Nadav Eiron <nadav@TheEirons.org>
2003-06-01 09:16:50 +00:00
Juli Mallett 283d23cbba Make prototype match code with regard to constness of args to the
function pointer passed in.
2003-06-01 06:43:39 +00:00
Marcel Moolenaar abbb0b30ce Build libthr by default on ia64. 2003-06-01 00:32:21 +00:00
Dag-Erling Smørgrav ae1e82627a Don't build pam_std_option(). 2003-05-31 23:38:16 +00:00
Jens Schweikhardt f8f6970098 Fix grammar bogons.
MFC after:	3 days
2003-05-31 21:14:41 +00:00
Marcel Moolenaar fae3c3b7eb Rough implement of makecontext() needed to support libthr.
o  Up to 8 arguments are allowed. This is the number of arguments
   passed in registers. Subsequent registers are passed on the stack.
   Trying to deal with this is not easy in C and likely forces us to
   use assembly code. Let's avoid that for now. There's no indication
   that more than 8 arguments is a strong requirement (Linux also has
   an 8 argument limit).
o  We expect that the stack base is 16-byte aligned and the stack
   size is a multiple of 16-byte. We bomb out if this is not the case.
   We probably want to be less strict by enforcing it ourselves. For
   now it's better to not hide gross alignment bogons by silently
   correcting it.
2003-05-31 19:42:51 +00:00
Mike Makonnen 31b8681181 Hook libthr to the build. It's currently built only for i386 and
a NOLIBTHR knob will prevent it from being built.
2003-05-31 18:43:17 +00:00
Dag-Erling Smørgrav 4d6991c692 Update copyright dates. 2003-05-31 17:19:03 +00:00
Dag-Erling Smørgrav f7d39b0967 Remove pam_std_option() and related functions. Add #defines for common
options.
2003-05-31 16:56:35 +00:00
Dag-Erling Smørgrav 545aa47101 Remove all instances of pam_std_option() 2003-05-31 16:55:07 +00:00
Dag-Erling Smørgrav d462d3923b Introduce pam_guest(8) which will replace pam_ftp(8). 2003-05-31 16:52:58 +00:00
Mike Makonnen 6e1aa51e9e I botched one of my committs in the last round. Fix it. 2003-05-31 14:38:22 +00:00
Ruslan Ermilov 61fa6d584f Fixed another bug in the threaded close() call; clear the
stale stdio descriptors flags.

PR:		bin/51535
Submitted by:	Enache Adrian <enache@rdslink.ro>
Reviewed by:	deischen
Approved by:	re (scottl)
2003-05-31 05:23:20 +00:00
Ruslan Ermilov d635dc4671 If an application closes one of its stdio descriptors (0..2),
an excessive close() on one of these descriptors would cause
a memory for this descriptor to be allocated in the internal
descriptor table.  When this descriptor gets used again, e.g.
through the call to open() or socket(), the descriptor would
be erroneously left in the blocking mode, and the whole
application would get stuck on a blocking operation, e.g.,
in accept(2).

Prevent this bug from happening by disallowing close() against
non-active descriptors (return -1 and set errno to EBADF in
this case).

Reviewed by:	deischen
Approved by:	re (scottl)
2003-05-31 05:20:44 +00:00
David Xu 9abece6475 Save THR_FLAGS_IN_TDLIST in signal frame, otherwise if a thread received
a signal will can not be removed from thread list after it exited.

Reviewed by: deischen
Approved by: re (jhb)
2003-05-30 14:50:16 +00:00
Thomas Moestl 6bc615b0a1 Fix a sizeof error in __bt_put: when writing they key and data sizes
to a buffer in the big key/data case, memmove() was used on pointers
to size_ts, but only sizeof(u_int32_t) bytes where copied. This broke
on big_endian architectures where sizeof(size_t) > sizeof(u_int32_t).

This bug broke portupgrade (by way of ruby_bdb1) on sparc64.

Approved by:	re (rwatson)
2003-05-30 11:05:08 +00:00
Alexander Kabaev 8c22e2f77b Add an stub for _rtld_thread_init. This is a part I missed in
my last commit.

Approved by:	re (scottl)
2003-05-30 00:58:37 +00:00
Alexander Kabaev 84d55c7fad Attempt to eliminate PLT relocations from rwlock aquire/release
path, making them suitable for direct use by the dynamic loader.

Register libpthread-specific locking API with rtld on startup.

This still has some rough edges with signals which should be
addresses later.

Approved by:	re (scottl)
2003-05-30 00:21:52 +00:00
Daniel Eischen 43dd76d242 Call the __sys_sigprocmask(the system call) when sigprocmask()
is called and the application is not threaded.  This works around
a problem when an application that hasn't yet become threaded
tries to jump out of a signal handler.

Reported by:	mbr
Approved by:	re@ (rwatson)
2003-05-30 00:09:22 +00:00
Martin Blapp 65d06145a2 Don't return -1 and abort if msg.msg_controllen is 0. For
some strange reason recvmsg() never sets errno to EAGAIN
on a non-blocking socket and just returns 0.

Reviewed by:	jhb
Approved by:	re
2003-05-29 22:06:06 +00:00
Mike Makonnen 1b2a19ce0e Make the mutex static initializers look more like the one for
condition variables. Cosmetic.

Explicitly compare against PTHREAD_MUTEX_INITIALIZER. We shouldn't
encourage calls to the mutex functions with null pointers to mutexes.

Approved by:	re/jhb
2003-05-29 20:58:31 +00:00
Mike Makonnen 41f2bd859f Use a static lock to ake sure pthread_cond_* functions called
from multiple threads don't initialze the same condition variable
more than once.

Explicitly compare cond pointers with PTHREAD_COND_INITIALIZER instead
of NULL. Just because it happens to be defined as NULL is no reason
to encourage the idea that people can call those functions with
NULL pointers to a condition variable.

Approved by:	re/jhb
2003-05-29 20:54:00 +00:00
Mike Makonnen 0e335eaeb5 Missing unlock.
Approved by:	re/jhb
2003-05-29 20:49:17 +00:00
Mike Makonnen b3cdf7ae2e Don't hold the active thread list lock when signaling the gc thread.
The dead list thread is sufficient for synchronization.

Retire the arch_id (ldt array slot) in the gc thread instead of the
doing it in the thread itself.

Approved by:	re/jhb
2003-05-29 20:46:53 +00:00
Mike Makonnen 981f4968f0 It's unnecessary to lock the thread during creation. Simply extend
the scope of the active thread list lock.

Approved by:	re/jhb
2003-05-29 20:40:50 +00:00
Martin Blapp e5cd12556d Fix a problem introduced in the last commit. sa and cm
are not initialized at this place. Move the initializing
before the non-blocking check.

Submitted by:	Marius Strobl <marius@alchemy.franken.de>
Reviewed by:	jhb
Approved by:	re
2003-05-29 19:43:22 +00:00
Daniel Eischen 28362a5c80 Don't really spin on a spinlock; silently convert it to the same
low-level lock used by the libpthread implementation.  In the
future, we'll eliminate spinlocks from libc but that will wait
until after 5.1-release.

Don't call an application signal handler if the handler is
the same as the library-installed handler.  This seems to
be possible after a fork and is the cause of konsole hangs.

Approved by:	re@ (jhb)
2003-05-29 17:10:45 +00:00
Martin Blapp aee2eba2d1 If AF_LOCAL is used, we need to use __msgread_withcred() instead of
just read() in non-blocking mode too. The reason is obvious. NetBSD
uses a complete different way to get the credentials so this patch
only applies to FreeBSD.

Reviewed by:	rwatson
Approved by:	re
2003-05-28 09:16:35 +00:00
Martin Blapp 22e4d31a81 Fix amd(8) clients, if a FreeBSD mountd(8) server is used.
Remove the special treatment of non-blocking mode in
the "look ahead function" xdrrec_eof(). It currently
assumes that the last read() in a row of several reads
does not have zero lenght. If this is the case, svc_vc_stat()
does return XPRT_MOREREQS, and the RPC-request aborts because
there is no data to read anymore.

To fix this, go back to the original version of the code
for non-blocking mode until NetBSD comes up with another
possible fix like this one in xdrrec_eof()

	if (rstrm->last_frag && rstrm->in_finger == rstrm->in_boundry) {
		return TRUE;
	}

Return always FALSE in set_input_fragment() for non-blocking
mode. Since this was not used in FreeBSD, I omitted it at the
first time. Now we use this function and we should always
return FALSE for it.

Reviewed by:	rwatson
Approved by:	re
2003-05-28 09:13:09 +00:00
Max Khon f4203da86c Fix stripping last path component when only one path component left.
PR:		52686
MFC after:	1 day
2003-05-28 08:23:01 +00:00
Mike Makonnen a09d02f780 Minimize the potential for deadlocks between an exiting thread and it's
joiner by making sure all locks and unlocks occur in the same order. For
the record the lock order is: DEAD_LIST, THREAD_LIST, exiting thread, joiner
thread.

Approved by: re/rwatson
2003-05-27 21:48:42 +00:00
Mike Makonnen ee98e9be9f Revert part of the last commit. I don't know what I was smoking.
Approved by: re/rwatson
2003-05-27 21:43:49 +00:00
Mike Makonnen ca1c469cc7 Decouple the thread stack [de]allocating functions from the 'dead threads list'
lock. It's not really necessary and we don't need the added complexity
or potential for deadlocks.

Approved by:	re/blanket libthr
2003-05-26 00:37:07 +00:00
Mike Makonnen 2387af9962 Revise the unlock order in _pthread_join(). Also, if the joined
thread is not dead, the join loop is guaranteed to execute at least
once, so there is no need to pick up the thread list lock after
we return from suspenstion only to release it after the loop.

Approved by:	re/blanket libthr
2003-05-26 00:28:49 +00:00
Mike Makonnen 12c407a424 Return gracefully, rather than aborting, when the maximum concurrent
threads per process has been reached. Return EAGAIN, as per spec.

Approved by:	re/blanket libthr
2003-05-25 22:40:57 +00:00
Mike Makonnen d39d651258 _pthread_cancel() breaks the normal lock order of first locking the
joined and then the joiner thread. There isn't an easy (sane?) way
to make it use the correct order without introducing races involving
the target thread and finding which (active or dead) list it is on. So,
after locking the canceled thread it will try to lock the joined thread
and if it fails release the first lock and try again from the top.

Introduce a new function, _spintrylock, which is simply a wrapper arround
umtx_trylock(), to help accomplish this.

Approved by: re/blanket libthr
2003-05-25 08:48:11 +00:00
Mike Makonnen 4393f2c4ec Part of the last patch.
Modify the thread creation and thread searching routine
to lock the thread lists with the new locks instead of GIANT_LOCK.

Approved by:	re/blanket libthr
2003-05-25 08:35:37 +00:00
Mike Makonnen 71d09bc86a Start locking up the active and dead threads lists. The active threads
list is protected by a spinlock_t, but the dead list uses a pthread_mutex
because it is necessary to synchronize other threads with the garbage
collector thread. Lock/Unlock macros are used so it's easier to make
changes to the locks in the future.

The 'dead thread list' lock is intended to replace the gc mutex.
This doesn't have any practical ramifications. It simply makes it
clearer what the purpose of the lock is. The gc will use this lock,
instead of the gc mutex, to synchronize access to the dead list with
other threads.

Modify _pthread_exit() to use these two new locks instead of GIANT_LOCK,
and also to properly lock and protect thread state changes,
especially with respect to a joining thread.

The gc thread was also re-arranged to be more organized and less nested.

_pthread_join() was also modified to use the thread list locks. However,
locking and unlocking here needs special care because a thread could find
itself in a position where it's joining an exiting thread that is
waiting on the dead list lock, which this thread (joiner) holds. If the
joiner doesn't take care to lock *and* unlock in the same order they
(the joiner and the joinee) could deadlock against each other.

Approved by:	re/blanket libthr
2003-05-25 08:31:33 +00:00
Mike Makonnen 6a1899ed5c The libthr code makes use of higher-level primitives (pthread_mutex_t and
pthread_cond_t) internaly in addition to the low-level spinlock_t. The
garbage collector mutex and condition variable are two such examples. This
might lead to critical sections nested within critical sections. Implement
a reference counting mechanism so that signals are masked only on the first
entry and unmasked on the last exit.

I'm not sure I like the idea of nested critical sections, but if
the library is going to use the pthread primitives it might be necessary.

Approved by:	re/blanket libthr
2003-05-25 07:58:22 +00:00
Marcel Moolenaar 9e14b94e43 The struct mcontext has changed. It's using the register sets. Bring
this in line.
2003-05-25 06:49:19 +00:00
Ruslan Ermilov 734ac3b543 mdoc(7) fixes.
Approved by:	re (blanket)
2003-05-24 19:53:08 +00:00
Peter Wemm b3aa27a531 Repair PIC mode. It seems I was a bit too excited about the
implications of native PC relative addressing.
2003-05-24 17:35:23 +00:00
Daniel Eischen 1cb570c531 Change low-level locking a bit so that we can tell if
a lock is being waitied on.

Fix a races in join and cancellation.

When trying to wait on a CV and the library is not yet
threaded, make it threaded so that waiting actually works.

When trying to nanosleep() and we're not threaded, just
call the system call nanosleep instead of adding the thread
to the wait queue.

Clean up adding/removing new threads to the "all threads queue",
assigning them unique ids, and tracking how many active threads
there are.  Do it all when the thread is added to the scheduling
queue instead of making pthread_create() know how to do it.

Fix a race where a thread could be marked for signal delivery
but it could be exited before we actually add the signal to it.

Other minor cleanups and bug fixes.

Submitted by:	davidxu
Approved by:	re@ (blanket for libpthread)
2003-05-24 02:29:25 +00:00
Mike Makonnen a224a3919d Lock the cond queue (condition variables):
Access to the thread's flags and state is protected by
_thread_critical_enter/exit(). When a thread is signaled with a condition
its state must be protected by locking it and disabling
signals before it is taken of the waiters' queue.

Move the implementation of pthread_cond_signal() and pthread_cond_broadcast()
into one function, cond_signal(). Its behaviour is determined by the
last argument, int broadcast. If this is set to 1 it will remove all
waiters, otherwise it will wake up only the first waiter thread.

Remove an extraneous call to pthread_testcancel().

Approved by:	re/blanket libthr
2003-05-24 01:02:16 +00:00
Mike Makonnen 59a47b31d0 Add two functions: _spinlock_pthread() and _spinunlock_pthread()
that take the address of a struct pthread as their first argument.
_spin[un]lock() just become wrappers arround these two functions.
These new functions are for use in situations where curthread can't be
used. One example is _thread_retire(), where we invalidate the array index
curthread uses to get its pointer..

Approved by:	re/blanket libthr
2003-05-23 23:39:31 +00:00
Mike Makonnen b32a99e5f4 EDOOFUS
Prevent one thread from messing up another thread's saved signal
mask by saving it in struct pthread instead of leaving it as a
global variable. D'oh!

Approved by:	re/blanket libthr
2003-05-23 10:28:13 +00:00
Mike Makonnen 7d9d7ca2ed Make WARNS2 clean. The fixes mostly included:
o removed unused variables
	o explicit inclusion of header files
	o prototypes for externally defined functions

Approved by:    re/blanket libthr
2003-05-23 09:48:20 +00:00
Mike Makonnen 4e3f7b6ede note to self: do not confuse void* with int.
Approved by:	re/blanket libthr
2003-05-23 08:13:24 +00:00
Mike Barcroft 6f9622a926 Fix two misuses of __BSD_VISIBLE.
Submitted by:	bde
Approved by:	re
2003-05-22 17:07:57 +00:00
Ruslan Ermilov 3a5146d9e2 Assorted mdoc(7) fixes.
Approved by:	re (blanket)
2003-05-22 13:02:28 +00:00
Mike Makonnen 509d72c4b9 o Make the defenition of _set_curthread() match its declaration
in thr_private.h

o Lock down the ldt_entries array and ldt_free, which points to
  the next free slot. As noted in the comments, it's necessary
  to special case the initial_thread because %gs is not setup
  for it yet. This is ok because that early in the program there
  won't be any reentrancy issues anyways.

Approved by:	re/blanket libthr
2003-05-21 08:21:24 +00:00
Mike Makonnen 6439d4c286 Insert a debugging aid:
When in either the mutex or cond queue we notice that the thread
 is already on one of the queues, don't just simply abort(). Print
 out the thread's identifiers and what queue it was on.

Approved by: markm/mentor, re/blanket libthr
2003-05-21 03:41:07 +00:00
Mike Makonnen 5ccf23715a Re-enable the garbage collector thread in anticipation of further
locking work. I can't see anything obviously wrong with it (other than
the need to update the locking).

Approved by: markm/mentor, re/blanket libthr
2003-05-21 03:34:54 +00:00
Mike Makonnen f97591bf25 When a thread exits it does not return from the kernel unless it
is the *only* remaining thread in the application, in which case we
should not core dump, and instead exit gracefully.

Approved by: markm/mentor, re/blanket libthr
2003-05-21 03:29:18 +00:00
Mike Makonnen 3f07b4bcbd The thread id was being set *before* zeroing out the thread. Reverse
the order.

Approved by: markm/mentor, re/blanket libthr
2003-05-21 03:22:36 +00:00
Mike Makonnen 9dc6e7848f Move a misplaced comment.
Approved by:	markm/mentor (implicit), re/blanket libthr
2003-05-20 18:48:41 +00:00
Daniel Eischen 28f318b941 Eek, staticize a couple of functions that shouldn't
be external (initialize()!).

Remove cancellation points from _pthread_cond_wait and
_pthread_cond_timedwait (single underscore versions are
libc private functions).  Point the weak reference(!) for
these functions to the versions with cancellation points.

Approved by:	re@(blanket till 5/19)
Pointed out by:	kan (cancellation point bug)
2003-05-19 23:04:50 +00:00
Dag-Erling Smørgrav 7691f66abf Retire the useless NOSECURE knob.
Approved by:	re (scottl)
2003-05-19 15:52:01 +00:00
Ruslan Ermilov aba60fa66b Fixed troff(1) and mdoc(7) warnings.
Approved by:	re (blanket)
2003-05-18 21:05:22 +00:00