3
A brief file description
5
@section license License
7
Licensed to the Apache Software Foundation (ASF) under one
8
or more contributor license agreements. See the NOTICE file
9
distributed with this work for additional information
10
regarding copyright ownership. The ASF licenses this file
11
to you under the Apache License, Version 2.0 (the
12
"License"); you may not use this file except in compliance
13
with the License. You may obtain a copy of the License at
15
http://www.apache.org/licenses/LICENSE-2.0
17
Unless required by applicable law or agreed to in writing, software
18
distributed under the License is distributed on an "AS IS" BASIS,
19
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
See the License for the specific language governing permissions and
21
limitations under the License.
24
/****************************************************************************
29
NetAccept is a generalized facility which allows
30
Connections of different classes to be accepted either
31
from a blockable thread or by adaptive polling.
33
It is used by the NetProcessor and the ClusterProcessor
34
and should be considered PRIVATE to processor implementations.
38
****************************************************************************/
39
#ifndef __P_NETACCEPT_H__
40
#define __P_NETACCEPT_H__
43
#include "P_Connection.h"
49
// Default accept function
50
// Accepts as many connections as possible, returning the number accepted
51
// or -1 to stop accepting.
53
typedef int (AcceptFunction) (NetAccept * na, void *e, bool blockable);
54
typedef AcceptFunction *AcceptFunctionPtr;
55
AcceptFunction net_accept;
57
class UnixNetVConnection;
59
// TODO fix race between cancel accept and call back
60
struct NetAcceptAction:public Action, public RefCountObj
64
void cancel(Continuation * cont = NULL) {
69
Continuation *operator =(Continuation * acont)
71
return Action::operator=(acont);
75
Debug("net_accept", "NetAcceptAction dying\n");
82
// Handles accepting connections.
84
struct NetAccept:public Continuation
91
AcceptFunctionPtr accept_fn;
94
bool callback_on_open;
95
Ptr<NetAcceptAction> action_;
98
uint32_t sockopt_flags;
100
UnixNetVConnection *epoll_vc; // only storage for epoll events
103
// Functions all THREAD_FREE and THREAD_ALLOC to be performed
104
// for both SSL and regular NetVConnection transparent to
106
virtual UnixNetVConnection *allocateThread(EThread *t);
107
virtual void freeThread(UnixNetVConnection *vc, EThread *t);
108
virtual UnixNetVConnection *allocateGlobal();
109
virtual EventType getEtype();
111
void init_accept_loop();
112
virtual void init_accept(EThread * t = NULL);
113
virtual void init_accept_per_thread();
115
int do_listen(bool non_blocking);
117
int do_blocking_accept(NetAccept * master_na, EThread * t);
118
virtual int acceptEvent(int event, void *e);
119
virtual int acceptFastEvent(int event, void *e);
120
int acceptLoopEvent(int event, Event * e);
124
virtual ~ NetAccept()