-
Notifications
You must be signed in to change notification settings - Fork 33
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
expose tcp_read/ssl_read errors #713
base: master
Are you sure you want to change the base?
Conversation
@@ -261,9 +261,14 @@ static int l_tm_tcp_read (lua_State* L) | |||
uint8_t buf[512]; | |||
size_t buf_len = sizeof(buf); | |||
int err = tm_tcp_read(socket, buf, &buf_len); | |||
(void) err; | |||
|
|||
if (err < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong. tm_tcp_read
returns errno
on error:
https://github.com/tessel/runtime/blob/master/src/posix/tm_net.c#L169
…which at least for the POSIX-defined errors are mandated to have positive values: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/errno.h.html
So: any non-zero value indicates error…the sign of the number should not be checked here, or you will certainly miss errors under POSIX (and probably CC3K too unless it happens to provide negative errno
values of its own…).
Glad this is getting hooked up — please see comments on patch though for some logic changes necessary to make it work as you intend for the |
@@ -195,9 +195,11 @@ TCPSocket.prototype.connect = function (/*options | [port], [host], [cb]*/) { | |||
var closeRet = tm.tcp_close(self.socket); // returns -57 if socket is already closed | |||
if (closeRet < 0 && closeRet != -tm.ENOTCONN){ | |||
// couldn't close socket, throw an error | |||
// failed to connect, stay silent | |||
console.log("Failed to close socket", self.socket); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the opposite of staying silent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But yeah, should we have internal code be emitting console.logs if it's just going to throw the error immediately?
@jiahuang is this just tying up loose ends, or was the missing error handling related to tessel/t1-firmware#128 too? |
This PR exposes HCI 1008 (select) errors on read so that it can be handled in the JS layer.