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

WIP: Deprecate SbSocket and migrate to socket APIs #2198

Closed
wants to merge 1 commit into from

Conversation

maxz-lab
Copy link
Contributor

SbSocketClearLastError -> errno
SbSocketGetLastError -> errno

b/302701164

Change-Id: Ie1c099743a8cec011c890c87cb0b23ec945ca1a0

@maxz-lab maxz-lab marked this pull request as draft January 11, 2024 18:24
@datadog-cobalt-youtube
Copy link

Datadog Report

Branch report: maxz-sb16-SbSocket24
Commit report: c881e8a
Test service: cobalt

✅ 0 Failed, 6140 Passed, 1 Skipped, 1m 50.27s Wall Time

@@ -105,11 +106,17 @@ bool Socket::IsPending() {
}

SbSocketError Socket::GetLastError() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to keep the return type of this to be SbSocketError in SB16+? Will we eventually stop using SbSocketError and move to int or no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would say NO, not going to carry the SbSocketError to SB16+.

SbSocketClearLastError -> errno
SbSocketGetLastError   -> errno

Replace SbSocketPrivate by SbSocketWrapper (temporarily)

SbSocketCreate -> socket

b/302701164

Change-Id: Ie1c099743a8cec011c890c87cb0b23ec945ca1a0
@@ -126,6 +137,41 @@ typedef struct SbSocketResolution {
// Well-defined value for an invalid socket handle.
#define kSbSocketInvalid ((SbSocket)NULL)

#if SB_API_VERSION >= 16
Copy link
Contributor

Choose a reason for hiding this comment

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

This code should go in starboard/common.
We don't allow c++ code in the starboard/foo.h headers.

#include "starboard/common/socket.h"
#else
#include <errno.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please file a bug to make <errno.h> work!

socket_ = SbSocketCreate(ConvertAddressFamily(family), kSbSocketProtocolTcp);
#else
int socket_fd = socket(ConvertSocketAddressTypeToDomain(ConvertAddressFamily(family)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just temporary till you get all the APIs adjusted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

errno = save_errno;
socket_ = kSbSocketInvalid;
} else {
socket_ = new SbSocketWrapper(ConvertAddressFamily(family), kSbSocketProtocolTcp, socket_fd);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need a SbSocketWrapper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Structure SbSocket members are associated to each other, like the address, the type, the error, and socket_waiter. It is convenient to keep them in a group.

@@ -314,6 +314,8 @@ ExportedSymbols::ExportedSymbols() {
REGISTER_SYMBOL(SbStringFormat);
REGISTER_SYMBOL(SbStringFormatWide);
REGISTER_SYMBOL(SbStringScan);
REGISTER_SYMBOL(SbSocketClearLastError);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you introducing new Starboard symbols in SB 16?

REGISTER_SYMBOL(SbSocketConnect);
#if SB_API_VERSION < 16
REGISTER_SYMBOL(SbSocketCreate);
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is the posix socket API registration?

@maxz-lab maxz-lab closed this Feb 29, 2024
@maxz-lab maxz-lab deleted the maxz-sb16-SbSocket24 branch February 29, 2024 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants