1123355Sdeischen/* 2123355Sdeischen * Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>. 3123355Sdeischen * All rights reserved. 4123355Sdeischen * 5123355Sdeischen * Redistribution and use in source and binary forms, with or without 6123355Sdeischen * modification, are permitted provided that the following conditions 7123355Sdeischen * are met: 8123355Sdeischen * 1. Redistributions of source code must retain the above copyright 9123355Sdeischen * notice, this list of conditions and the following disclaimer. 10123355Sdeischen * 2. Neither the name of the author nor the names of any co-contributors 11123355Sdeischen * may be used to endorse or promote products derived from this software 12123355Sdeischen * without specific prior written permission. 13123355Sdeischen * 14123355Sdeischen * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15123355Sdeischen * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16123355Sdeischen * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17123355Sdeischen * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18123355Sdeischen * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19123355Sdeischen * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20123355Sdeischen * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21123355Sdeischen * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22123355Sdeischen * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23123355Sdeischen * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24123355Sdeischen * SUCH DAMAGE. 25123355Sdeischen */ 26123355Sdeischen 27123355Sdeischen#include <sys/cdefs.h> 28123355Sdeischen__FBSDID("$FreeBSD$"); 29123355Sdeischen 30123355Sdeischen#include <sys/types.h> 31123355Sdeischen#include <sys/socket.h> 32123355Sdeischen#include <pthread.h> 33123355Sdeischen#include "thr_private.h" 34123355Sdeischen 35174112Sdeischenint __accept(int s, struct sockaddr *addr, socklen_t *addrlen); 36174112Sdeischen 37123355Sdeischen__weak_reference(__accept, accept); 38123355Sdeischen 39123355Sdeischenint 40123355Sdeischen__accept(int s, struct sockaddr *addr, socklen_t *addrlen) 41123355Sdeischen{ 42123355Sdeischen struct pthread *curthread; 43123355Sdeischen int ret; 44123355Sdeischen 45123355Sdeischen curthread = _get_curthread(); 46123355Sdeischen _thr_cancel_enter(curthread); 47123355Sdeischen ret = __sys_accept(s, addr, addrlen); 48123365Sdeischen _thr_cancel_leave(curthread, ret == -1); 49123355Sdeischen 50123355Sdeischen return (ret); 51123355Sdeischen} 52