Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions iocore/dns/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
add_library(inkdns STATIC
DNS.cc
DNSConnection.cc
DNSEventIO.cc
Inline.cc
SplitDNS.cc
)
Expand Down
2 changes: 1 addition & 1 deletion iocore/dns/DNS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ DNSHandler::open_con(sockaddr const *target, bool failed, int icon, bool over_tc
}
return false;
} else {
if (cur_con.eio.start(pd, &cur_con, EVENTIO_READ) < 0) {
if (cur_con.eio.start(pd, cur_con.fd, EVENTIO_READ) < 0) {
Error("[iocore_dns] open_con: Failed to add %d server to epoll list\n", icon);
} else {
cur_con.num = icon;
Expand Down
35 changes: 35 additions & 0 deletions iocore/dns/DNSEventIO.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
@section license License

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "DNSEventIO.h"
#include "P_DNSConnection.h"

int
DNSEventIO::start(EventLoop l, int fd, int events)
{
return start_common(l, fd, events);
}

void
DNSEventIO::process_event(int flags)
{
_c.trigger(); // Make sure the DNSHandler for this con knows we triggered
refresh(EVENTIO_READ);
}
46 changes: 46 additions & 0 deletions iocore/dns/DNSEventIO.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/** @file

A brief file description

@section license License

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/**************************************************************************

P_DNSConnection.h
Description:
struct DNSConnection
**************************************************************************/

#pragma once

#include "EventIO.h"

struct DNSConnection;

class DNSEventIO : public EventIO
{
public:
DNSEventIO(DNSConnection &c) : EventIO(), _c(c) {}
int start(EventLoop l, int fd, int events);
void process_event(int flags) override;

private:
DNSConnection &_c;
};
1 change: 1 addition & 0 deletions iocore/dns/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ noinst_LIBRARIES = libinkdns.a
libinkdns_a_SOURCES = \
DNS.cc \
DNSConnection.cc \
DNSEventIO.cc \
I_DNS.h \
I_DNSProcessor.h \
I_SplitDNS.h \
Expand Down
5 changes: 2 additions & 3 deletions iocore/dns/P_DNSConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@

#pragma once

#include "I_EventSystem.h"
#include "DNSEventIO.h"
#include "I_DNSProcessor.h"
#include "EventIO.h"

//
// Connection
Expand Down Expand Up @@ -79,7 +78,7 @@ struct DNSConnection {
int num = 0;
Options opt;
LINK(DNSConnection, link);
EventIO eio;
DNSEventIO eio{*this};
InkRand generator;
DNSHandler *handler = nullptr;

Expand Down
41 changes: 41 additions & 0 deletions iocore/io_uring/IOUringEventIO.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/** @file

A brief file description

@section license License

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "IOUringEventIO.h"
#if TS_USE_LINUX_IO_URING
#include "I_IO_URING.h"

int
IOUringEventIO::start(EventLoop l, IOUringContext *h)
{
_h = h;
int fd = _h->register_eventfd();
return start_common(l, fd, EVENTIO_READ);
}

void
IOUringEventIO::process_event(int flags)
{
_h->service();
}
#endif
40 changes: 40 additions & 0 deletions iocore/io_uring/IOUringEventIO.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/** @file

A brief file description

@section license License

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#pragma once
#include "tscore/ink_config.h"
#if TS_USE_LINUX_IO_URING
#include "../net/EventIO.h"

class IOUringContext;
class IOUringEventIO : public EventIO
{
public:
IOUringEventIO() : EventIO() {}
int start(EventLoop l, IOUringContext *h);
void process_event(int flags) override;

private:
IOUringContext *_h;
};
#endif
2 changes: 2 additions & 0 deletions iocore/io_uring/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ AM_CPPFLAGS += \
noinst_LIBRARIES = libinkuring.a

libinkuring_a_SOURCES = \
IOUringEventIO.cc \
IOUringEventIO.h \
io_uring.cc \
I_IO_URING.h \
P_IO_URING.h
Expand Down
45 changes: 45 additions & 0 deletions iocore/net/AsyncSignalEventIO.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**@file

A brief file description

@section license License

Licensed to the Apache Software
Foundation(ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "AsyncSignalEventIO.h"
#include "I_EThread.h"

int
AsyncSignalEventIO::start(EventLoop l, int fd, int events)
{
_fd = fd;
return start_common(l, fd, events);
}

void
AsyncSignalEventIO::process_event(int flags)
{
#if HAVE_EVENTFD
uint64_t counter;
static_cast<void>(read(_fd, &counter, sizeof(uint64_t)));
#else
char dummy[1024];
static_cast<void>(read(_fd, &dummy[0], 1024));
#endif
}
39 changes: 39 additions & 0 deletions iocore/net/AsyncSignalEventIO.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**@file

A brief file description

@section license License

Licensed to the Apache Software
Foundation(ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#pragma once

#include "EventIO.h"

class EThread;

class AsyncSignalEventIO : public EventIO
{
public:
int start(EventLoop l, int fd, int events);

void process_event(int flags) override;

private:
int _fd;
};
4 changes: 4 additions & 0 deletions iocore/net/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
add_library(inknet STATIC
AcceptOptions.cc
ALPNSupport.cc
AsyncSignalEventIO.cc
BIO_fastopen.cc
BoringSSLUtils.cc
Connection.cc
Expand All @@ -28,9 +29,11 @@ add_library(inknet STATIC
Net.cc
NetHandler.cc
NetVCOptions.cc
NetAcceptEventIO.cc
NetVConnection.cc
PollCont.cc
ProxyProtocol.cc
ReadWriteEventIO.cc
Socks.cc
SSLCertLookup.cc
SSLClientCoordinator.cc
Expand All @@ -57,6 +60,7 @@ add_library(inknet STATIC
TLSSessionResumptionSupport.cc
TLSSNISupport.cc
TLSTunnelSupport.cc
UDPEventIO.cc
UDPIOEvent.cc
UnixConnection.cc
UnixNet.cc
Expand Down
Loading