constexpr const int MAX_PAYLOAD_SIZE = 1024 * 1024 * 1;
constexpr const char PATH_AUL_SOCKET_TIMEOUT[] = "/run/aul/.socket_timeout";
constexpr const char PATH_AMD_SOCK[] = "/run/aul/daemons/.amd-sock";
-int MAX_FDS = sysconf(_SC_OPEN_MAX);
constexpr unsigned int SOCKET_TIMEOUT_MIN = 5000U;
constexpr unsigned int SOCKET_TIMEOUT_MAX = 30000U;
}
extern "C" API int aul_sock_set_sock_option(int fd, int cli) {
- if (fd < 0 || fd >= MAX_FDS) {
+ if (fd < 0 || fd >= sysconf(_SC_OPEN_MAX)) {
_E("Invalid parameter");
return -EINVAL;
}
extern "C" API int aul_sock_send_raw_with_fd(int fd, int cmd,
unsigned char* kb_data, int datalen, int opt) {
- if (fd < 0 || fd >= MAX_FDS) {
+ if (fd < 0 || fd >= sysconf(_SC_OPEN_MAX)) {
_E("Invalid parameter");
return -EINVAL;
}
extern "C" API int aul_sock_send_bundle_with_fd(int fd, int cmd, bundle* kb,
int opt) {
- if (fd < 0 || fd >= MAX_FDS || kb == nullptr) {
+ if (fd < 0 || fd >= sysconf(_SC_OPEN_MAX) || kb == nullptr) {
_E("Invalid parameter");
return -EINVAL;
}
extern "C" API app_pkt_t* aul_sock_recv_pkt(int fd, int* clifd,
struct ucred* cred) {
- if (fd < 0 || fd >= MAX_FDS) {
+ if (fd < 0 || fd >= sysconf(_SC_OPEN_MAX)) {
_E("Invalid parameter");
return nullptr;
}
extern "C" API int aul_sock_recv_reply_sock_fd(int fd, int (*ret_fd)[2],
int fd_size) {
- if (fd < 0 || fd >= MAX_FDS) {
+ if (fd < 0 || fd >= sysconf(_SC_OPEN_MAX)) {
_E("Invalid parameter");
return -EINVAL;
}
extern "C" API int aul_sock_recv_pkt_with_cb(int fd,
void (*callback)(app_pkt_t* pkt, void* user_data),
void* user_data) {
- if (fd < 0 || fd >= MAX_FDS) {
+ if (fd < 0 || fd >= sysconf(_SC_OPEN_MAX)) {
_E("Invalid parameter");
return -1;
}
}
extern "C" API int aul_sock_recv_result_with_fd(int fd) {
- if (fd < 0 || fd >= MAX_FDS) {
+ if (fd < 0 || fd >= sysconf(_SC_OPEN_MAX)) {
_E("Invalid parameter");
return -EINVAL;
}
}
extern "C" API int aul_sock_destroy_server(int fd) {
- if (fd > -1 && fd < MAX_FDS)
+ if (fd > -1 && fd < sysconf(_SC_OPEN_MAX))
close(fd);
if (getuid() < REGULAR_UID_MIN) {
}
extern "C" API int aul_sock_send_result_v2(int fd, int res, bool do_close) {
- if (fd < 0 || fd >= MAX_FDS) {
+ if (fd < 0 || fd >= sysconf(_SC_OPEN_MAX)) {
_E("Invalid parameter");
return -EINVAL;
}
extern "C" API int aul_sock_recv_reply_pkt_v2(int fd, app_pkt_t** pkt,
bool do_close) {
- if (fd < 0 || fd >= MAX_FDS) {
+ if (fd < 0 || fd >= sysconf(_SC_OPEN_MAX)) {
_E("Invalid parameter");
return -EINVAL;
}