Skip to content
This repository was archived by the owner on Dec 16, 2019. It is now read-only.

Added static method Socket::createListen()#844

Open
sirsnyder wants to merge 1 commit intomasterfrom
socket_create_listen
Open

Added static method Socket::createListen()#844
sirsnyder wants to merge 1 commit intomasterfrom
socket_create_listen

Conversation

@sirsnyder
Copy link
Copy Markdown
Collaborator

@sirsnyder sirsnyder commented Feb 27, 2018

  • Static method createListen() wraps create(), bind() and listen() in one call
  • added one test

@sirsnyder sirsnyder force-pushed the socket_create_listen branch from 70dfe10 to f89a332 Compare February 28, 2018 23:26
#else
if ((hp = php_network_gethostbyname("localhost")) == NULL) {
#endif
zval_ptr_dtor(return_value);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@tpunt is zval_ptr_dtor used correctly at this point and below?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks fine to me. Technically, zval_dtor could be used, since we know that the newly created socket object will not contain a cycle (so there's no need to place it into the GC root buffer). But it doesn't really matter.

@sirsnyder
Copy link
Copy Markdown
Collaborator Author

@dktapps @tpunt please review

pthreads_object_t *created;
pthreads_socket_t *sock;

object_init_ex(return_value, pthreads_socket_entry);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This can return FAILURE. It's not immediately clear to me if any such paths exists where this can fail (from a quick look through the source code), but it may be worthwhile checking its return value for failure just in case I've missed some psychotic edge case.

PHP_ME(Socket, close, Socket_void, ZEND_ACC_PUBLIC)
PHP_ME(Socket, getLastError, Socket_getLastError, ZEND_ACC_PUBLIC)
PHP_ME(Socket, clearError, Socket_void, ZEND_ACC_PUBLIC)
PHP_ME(Socket, createListen, Socket_void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't look right. A separate arginfo needs to be defined for this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants