代码拉取完成,页面将自动刷新
同步操作将从 alibaba/PhotonLibOS 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
Copyright 2022 The Photon Authors
Licensed 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 "photon.h"
#include "io/fd-events.h"
#include "io/signal.h"
#include "io/aio-wrapper.h"
#ifdef ENABLE_FSTACK_DPDK
#include "io/fstack-dpdk.h"
#endif
#include "net/curl.h"
#include "net/socket.h"
#include "fs/exportfs.h"
namespace photon {
using namespace fs;
using namespace net;
static thread_local uint64_t g_event_engine = 0, g_io_engine = 0;
#define INIT_IO(name, prefix) if (INIT_IO_##name & io_engine) { if (prefix##_init() < 0) return -1; }
#define FINI_IO(name, prefix) if (INIT_IO_##name & g_io_engine) { prefix##_fini(); }
// Try to init master engine with the recommended order
#if defined(__linux__)
static const int recommended_order[] = {INIT_EVENT_EPOLL, INIT_EVENT_IOURING, INIT_EVENT_SELECT};
#else // macOS, FreeBSD ...
static const int recommended_order[] = {INIT_EVENT_KQUEUE, INIT_EVENT_SELECT};
#endif
int init(uint64_t event_engine, uint64_t io_engine) {
if (vcpu_init() < 0)
return -1;
if (event_engine != INIT_EVENT_NONE) {
bool ok = false;
for (auto each : recommended_order) {
if ((each & event_engine) && fd_events_init(each) == 0) {
ok = true;
break;
}
}
if (!ok) {
LOG_ERROR_RETURN(0, -1, "All master engines init failed");
}
}
if ((INIT_EVENT_SIGNAL & event_engine) && sync_signal_init() < 0)
return -1;
#ifdef ENABLE_FSTACK_DPDK
INIT_IO(FSTACK_DPDK, fstack_dpdk);
#endif
INIT_IO(EXPORTFS, exportfs)
INIT_IO(LIBCURL, libcurl)
#ifdef __linux__
INIT_IO(LIBAIO, libaio_wrapper)
INIT_IO(SOCKET_EDGE_TRIGGER, et_poller)
#endif
g_event_engine = event_engine;
g_io_engine = io_engine;
return 0;
}
int fini() {
#ifdef __linux__
FINI_IO(LIBAIO, libaio_wrapper)
FINI_IO(SOCKET_EDGE_TRIGGER, et_poller)
#endif
FINI_IO(LIBCURL, libcurl)
FINI_IO(EXPORTFS, exportfs)
#ifdef ENABLE_FSTACK_DPDK
FINI_IO(FSTACK_DPDK, fstack_dpdk)
#endif
if (INIT_EVENT_SIGNAL & g_event_engine)
sync_signal_fini();
fd_events_fini();
vcpu_fini();
g_event_engine = g_io_engine = 0;
return 0;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。