Skip Menu |
 

This queue is for tickets about the Net-SSLeay CPAN distribution.

Report information
The Basics
Id: 95333
Status: resolved
Priority: 0/
Queue: Net-SSLeay

People
Owner: MIKEM [...] cpan.org
Requestors: and [...] gmx.li
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: peek() support for 2-item list context returns
Download (untitled) / with headers
text/plain 1.4k
Hi, as of Net::SSLeay v1.58 peek() returns with data or undef on error only. For better non-blocking support, peek() should returns underlaying error code, if requested by 2-item list context. So, lets handle peek() returns logic like read() it does. # returns: # in scalar context: data read from the TLS/SSL connection, undef on error # in list context: two-item array consisting of data read (undef on error), # and return code from SSL_peek(). --- a/SSLeay.xs 2014-05-01 00:00:00.000000000 +0000 +++ b/SSLeay.xs 2014-05-01 00:00:00.000000000 +0000 @@ -1411,11 +1411,25 @@ PREINIT: char *buf; int got; - CODE: + PPCODE: New(0, buf, max, char); - ST(0) = sv_newmortal(); /* Undefined to start with */ - if ((got = SSL_peek(s, buf, max)) >= 0) - sv_setpvn( ST(0), buf, got); + got = SSL_peek(s, buf, max); + + /* If in list context, return 2-item list: + * first return value: data gotten, or undef on error (got<0) + * second return value: result from SSL_peek() + */ + if (GIMME_V==G_ARRAY) { + EXTEND(SP, 2); + PUSHs(sv_2mortal(got>=0 ? newSVpvn(buf, got) : newSV(0))); + PUSHs(sv_2mortal(newSViv(got))); + + /* If in scalar or void context, return data gotten, or undef on error. */ + } else { + EXTEND(SP, 1); + PUSHs(sv_2mortal(got>=0 ? newSVpvn(buf, got) : newSV(0))); + } + Safefree(buf);
Subject: Re: [rt.cpan.org #95333] peek() support for 2-item list context returns
Date: Mon, 05 May 2014 07:35:15 +1000
To: bug-Net-SSLeay [...] rt.cpan.org
From: Mike McCauley <mikem [...] airspayce.com>
Download (untitled) / with headers
text/plain 2.3k
Hi, Thanks for your patch. Its is now in SVN 401 and will appear in the next release. Cheers. On Sunday, May 04, 2014 05:25:31 AM you wrote: Show quoted text
> Sun May 04 05:25:30 2014: Request 95333 was acted upon. > Transaction: Ticket created by and@gmx.li > Queue: Net-SSLeay > Subject: peek() support for 2-item list context returns > Broken in: (no value) > Severity: Normal > Owner: Nobody > Requestors: and@gmx.li > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=95333 > > > > Hi, > as of Net::SSLeay v1.58 peek() returns with data or undef on error only. > > For better non-blocking support, peek() should returns underlaying error > code, if requested by 2-item list context. > > So, lets handle peek() returns logic like read() it does. > > # returns: > # in scalar context: data read from the TLS/SSL connection, undef on error > # in list context: two-item array consisting of data read (undef on > error), # and return code from SSL_peek(). > > --- a/SSLeay.xs 2014-05-01 00:00:00.000000000 +0000 > +++ b/SSLeay.xs 2014-05-01 00:00:00.000000000 +0000 > @@ -1411,11 +1411,25 @@ > PREINIT: > char *buf; > int got; > - CODE: > + PPCODE: > New(0, buf, max, char); > - ST(0) = sv_newmortal(); /* Undefined to start with */ > - if ((got = SSL_peek(s, buf, max)) >= 0) > - sv_setpvn( ST(0), buf, got); > + got = SSL_peek(s, buf, max); > + > + /* If in list context, return 2-item list: > + * first return value: data gotten, or undef on error (got<0) > + * second return value: result from SSL_peek() > + */ > + if (GIMME_V==G_ARRAY) { > + EXTEND(SP, 2); > + PUSHs(sv_2mortal(got>=0 ? newSVpvn(buf, got) : newSV(0))); > + PUSHs(sv_2mortal(newSViv(got))); > + > + /* If in scalar or void context, return data gotten, or undef on > error. */ + } else { > + EXTEND(SP, 1); > + PUSHs(sv_2mortal(got>=0 ? newSVpvn(buf, got) : newSV(0))); > + } > + > Safefree(buf);
-- Mike McCauley VK4AMM mikem@airspayce.com Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia http://www.airspayce.com Phone +61 7 5598-7474 Fax +61 7 5598-7070


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.