[Snek] [PATCH v3] snekserver: allow network connections to a snigle Snek instance

Misha Gusarov dottedmag at dottedmag.net
Sun Apr 19 03:24:19 PDT 2020


On 18 Apr 2020, at 19:52, Keith Packard wrote:

> Very cool. I'm thinking of doing a 1.4 release when you're happy with
> the EV3 bits.

OK. I'll send implementation of reset/eeprom soon too.

>> +	struct sigaction act = {
>> +		.sa_handler = on_sigint,
>> +		.sa_flags = SA_RESTART,
>
> Hrm. I *think* you don't want SA_RESTART here. With this, a ^C sent
> while snek is waiting for I/O in the kernel will not interrupt the
> syscall, and so snek will keep waiting forever. You should be able to
> test this by sending ^C while snek is paused at the command prompt. That
> should cause snek wake up and reset stuff.

Yes, you're right.

>> +static int
>> +poll_noeintr(struct pollfd fds[], nfds_t nfds, int timeout)
>> +{
>> +	for (;;) {
>> +		int ret = poll(fds, nfds, timeout);
>> +		if (ret == -1 && (errno == EINTR || errno == EAGAIN))
>> +			continue;
>
> And here's where you'd want to test for snek_abort.

Poll is in snekserver, right? It does not run Snek.

>> +static int
>> +recv_noeintr(int socket, void *buffer, size_t length, int flags)
>> +{
>> +	for (;;) {
>> +		int ret = recv(socket, buffer, length, flags);
>> +		if (ret == -1 && (errno == EINTR || errno == EAGAIN))
>> +			continue;
>
> This one shouldn't include EAGAIN as that only happens on non-blocking
> sockets if there isn't any data to receive.

OK.


More information about the Snek mailing list