Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build on OpenBSD #5186

Merged
merged 2 commits into from
Nov 16, 2023
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
21 changes: 19 additions & 2 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -944,9 +944,26 @@ EOF
CFLAGS="-Wall -pthread $CFLAGS"
LDFLAGS="$LDFLAGS -lpthread"

if test "$SW_OS" != "MAC"; then
dnl Check should we link to librt
OS_SHOULD_HAVE_LIBRT=1

if test "$SW_OS" = "MAC"; then
OS_SHOULD_HAVE_LIBRT = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the build on macOS

#5194

fi
AS_CASE([$host_os],
[openbsd*], [OS_SHOULD_HAVE_LIBRT=0]
)

if test "x$OS_SHOULD_HAVE_LIBRT" = "x1"; then
AC_MSG_NOTICE([Librt is required on $host_os.])
dnl Check for the existence of librt
AC_CHECK_LIB([rt], [clock_gettime], [], [
AC_MSG_ERROR([We have to link to librt on your os, but librt not found.])
])
PHP_ADD_LIBRARY(rt, 1, SWOOLE_SHARED_LIBADD)
fi
else
AC_MSG_NOTICE([$host_os doesn't have librt -- don't link to librt.])
fi

if test "$SW_OS" = "LINUX"; then
LDFLAGS="$LDFLAGS -z now"
Expand Down
45 changes: 43 additions & 2 deletions ext-src/swoole_admin_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static json get_socket_info(int fd) {
};
return return_value.dump();
}
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__)
json jinfo{
{"state", info.tcpi_state},
{"ca_state", info.__tcpi_ca_state},
Expand Down Expand Up @@ -215,6 +215,47 @@ static json get_socket_info(int fd) {
{"rcv_ooopack", info.tcpi_rcv_ooopack},
{"snd_zerowin", info.tcpi_snd_zerowin},
};
#elif defined(__OpenBSD__)
json jinfo{
{"state", info.tcpi_state},
{"ca_state", info.__tcpi_ca_state},
{"retransmits", info.__tcpi_retransmits},
{"probes", info.__tcpi_probes},
{"backoff", info.__tcpi_backoff},
{"options", info.tcpi_options},
{"snd_wscale", uint8_t(info.tcpi_snd_wscale)},
{"rcv_wscale", uint8_t(info.tcpi_rcv_wscale)},
{"rto", info.tcpi_rto},
{"ato", info.__tcpi_ato},
{"snd_mss", info.tcpi_snd_mss},
{"rcv_mss", info.tcpi_rcv_mss},
{"unacked", info.__tcpi_unacked},
{"sacked", info.__tcpi_sacked},
{"lost", info.__tcpi_lost},
{"retrans", info.__tcpi_retrans},
{"fackets", info.__tcpi_fackets},
{"last_data_sent", info.tcpi_last_data_sent},
{"last_ack_sent", info.tcpi_last_ack_sent},
{"last_data_recv", info.tcpi_last_data_recv},
{"last_ack_recv", info.tcpi_last_ack_recv},
{"pmtu", info.__tcpi_pmtu},
{"rcv_ssthresh", info.__tcpi_rcv_ssthresh},
{"rtt", info.tcpi_rtt},
{"rttvar", info.tcpi_rttvar},
{"snd_ssthresh", info.tcpi_snd_ssthresh},
{"snd_cwnd", info.tcpi_snd_cwnd},
{"advmss", info.__tcpi_advmss},
{"reordering", info.__tcpi_reordering},
{"rcv_rtt", info.__tcpi_rcv_rtt},
{"rcv_space", info.tcpi_rcv_space},
{"snd_wnd", info.tcpi_snd_wnd},
{"snd_nxt", info.tcpi_snd_nxt},
{"rcv_nxt", info.tcpi_rcv_nxt},
{"toe_tid", info.tcpi_toe_tid},
{"total_retrans", info.tcpi_snd_rexmitpack},
{"rcv_ooopack", info.tcpi_rcv_ooopack},
{"snd_zerowin", info.tcpi_snd_zerowin},
};
#else
json jinfo{
{"state", info.tcpi_state},
Expand Down Expand Up @@ -250,7 +291,7 @@ static json get_socket_info(int fd) {
{"rcv_space", info.tcpi_rcv_space},
{"total_retrans", info.tcpi_total_retrans},
};
#endif
#endif // defined(__FreeBSD__) || defined(__NetBSD__)
return jinfo;
}
#endif
Expand Down
Loading