Skip to content

Commit

Permalink
update cr
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Dec 4, 2024
1 parent 6fcd019 commit 31a9a95
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
3 changes: 0 additions & 3 deletions include/aws/io/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

#include <aws/io/channel.h>
#include <aws/io/event_loop.h>
#include <aws/io/io.h>

AWS_PUSH_SANE_WARNING_LEVEL
Expand Down Expand Up @@ -138,8 +137,6 @@ struct aws_socket_endpoint {
uint32_t port;
};

struct aws_socket;

struct aws_socket {
struct aws_socket_vtable *vtable;
struct aws_allocator *allocator;
Expand Down
10 changes: 5 additions & 5 deletions source/event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,30 +656,30 @@ static int aws_event_loop_type_validate_platform(enum aws_event_loop_type type)
switch (type) {
case AWS_EVENT_LOOP_EPOLL:
#ifndef AWS_ENABLE_EPOLL
AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Event loop type EPOLL is not supported on the platform.");
AWS_LOGF_ERROR(AWS_LS_IO_EVENT_LOOP, "Event loop type EPOLL is not supported on the platform.");
return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED);
#endif // AWS_ENABLE_EPOLL
break;
case AWS_EVENT_LOOP_IOCP:
#ifndef AWS_ENABLE_IO_COMPLETION_PORTS
AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Event loop type IOCP is not supported on the platform.");
AWS_LOGF_ERROR(AWS_LS_IO_EVENT_LOOP, "Event loop type IOCP is not supported on the platform.");
return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED);
#endif // AWS_ENABLE_IO_COMPLETION_PORTS
break;
case AWS_EVENT_LOOP_KQUEUE:
#ifndef AWS_ENABLE_KQUEUE
AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Event loop type KQUEUE is not supported on the platform.");
AWS_LOGF_ERROR(AWS_LS_IO_EVENT_LOOP, "Event loop type KQUEUE is not supported on the platform.");
return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED);
#endif // AWS_ENABLE_KQUEUE
break;
case AWS_EVENT_LOOP_DISPATCH_QUEUE:
#ifndef AWS_ENABLE_DISPATCH_QUEUE
AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Event loop type Dispatch Queue is not supported on the platform.");
AWS_LOGF_ERROR(AWS_LS_IO_EVENT_LOOP, "Event loop type Dispatch Queue is not supported on the platform.");
return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED);
#endif // AWS_ENABLE_DISPATCH_QUEUE
break;
default:
AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Invalid event loop type.");
AWS_LOGF_ERROR(AWS_LS_IO_EVENT_LOOP, "Invalid event loop type.");
return aws_raise_error(AWS_ERROR_UNSUPPORTED_OPERATION);
break;
}
Expand Down
19 changes: 9 additions & 10 deletions source/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,25 @@ bool aws_socket_is_open(struct aws_socket *socket) {
* function failed to retrieve the default type value.
*/
static enum aws_socket_impl_type aws_socket_get_default_impl_type(void) {
enum aws_socket_impl_type type = AWS_SOCKET_IMPL_PLATFORM_DEFAULT;
// override default socket
#ifdef AWS_USE_APPLE_NETWORK_FRAMEWORK
type = AWS_SOCKET_IMPL_APPLE_NETWORK_FRAMEWORK;
#endif // AWS_USE_APPLE_NETWORK_FRAMEWORK
if (type != AWS_SOCKET_IMPL_PLATFORM_DEFAULT) {
return type;
}
return AWS_SOCKET_IMPL_APPLE_NETWORK_FRAMEWORK;
#else // ! AWS_USE_APPLE_NETWORK_FRAMEWORK
/**
* Ideally we should use the platform definition (e.x.: AWS_OS_APPLE) here, however the platform
* definition was declared in aws-c-common. We probably do not want to introduce extra dependency here.
*/
#if defined(AWS_ENABLE_KQUEUE) || defined(AWS_ENABLE_EPOLL)
# if defined(AWS_ENABLE_KQUEUE) || defined(AWS_ENABLE_EPOLL)
return AWS_SOCKET_IMPL_POSIX;
#elif AWS_ENABLE_DISPATCH_QUEUE
# elif defined(AWS_ENABLE_DISPATCH_QUEUE)
return AWS_SOCKET_IMPL_APPLE_NETWORK_FRAMEWORK;
#elif AWS_ENABLE_IO_COMPLETION_PORTS
# elif defined(AWS_ENABLE_IO_COMPLETION_PORTS)
return AWS_SOCKET_IMPL_WINSOCK;
#else
# else
AWS_FATAL_ASSERT(
true && "Invalid default socket impl type. Please check make sure the library is compiled the correct ");
return AWS_SOCKET_IMPL_PLATFORM_DEFAULT;
# endif
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions source/windows/iocp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ static int s_socket_init(
struct aws_allocator *alloc,
const struct aws_socket_options *options,
bool create_underlying_socket) {
AWS_ASSERT(options->domain <= AWS_SOCKET_LOCAL);
AWS_ASSERT(options->type <= AWS_SOCKET_DGRAM);
AWS_FATAL_ASSERT(options->domain <= AWS_SOCKET_LOCAL);
AWS_FATAL_ASSERT(options->type <= AWS_SOCKET_DGRAM);
AWS_ZERO_STRUCT(*socket);

struct iocp_socket *impl = aws_mem_calloc(alloc, 1, sizeof(struct iocp_socket));
Expand Down

0 comments on commit 31a9a95

Please sign in to comment.