1755388 Members
2857 Online
108832 Solutions
New Discussion юеВ

pty dropping data

 
SOLVED
Go to solution
Salvador Fandino
New Member

pty dropping data

Hi,

I am trying to solve a bug on the perl module Net::SFTP::Foreign (http://rt.cpan.org/Ticket/Display.html?id=35888).

To handle password authentication, Expect is used under the hood and the interprocess communication goes through a PTY. The module does IO in a select loop and the NONBLOCK fcntl flag is set on the PTY.

I have found that writing more than 512 bytes of data to the PTY causes HP-UX to discard the excess (I have used truss to see what was going on, and I am sure the data is discarded at the OS level!). Performing too many consecutive small write operations have the same effect.

Is there anyway to stop that from happening?

9 REPLIES 9
James R. Ferguson
Acclaimed Contributor
Solution

Re: pty dropping data

Hi:

Interesting. I see that you are actually the maintainer of this module and that the bug was reported to CPAN in the last week.

Moreover, "The same problem occurs on a "put" transfer from an AIX machine.".

For HP-UX it looks like the problem was reported on 11.11 on a PA-RISC platform using a 64-bit Perl 5.8.7.

One avenue to follow might be to make sure that the latest streams patch for 11.11 has been applied:

PHNE_36441

Regards!

...JRF...



Salvador Fandino
New Member

Re: pty dropping data

Actually I am using one of the test machines provided by HP for testing at http://www.testdrive.hp.com/ :

$ uname -a
HP-UX td191 B.11.31 U 9000/800 3397116299 unlimited-user license

How can I check it PHNE_36441 has been applied?
James R. Ferguson
Acclaimed Contributor

Re: pty dropping data

Hi (again) Salvador:

> How can I check it PHNE_36441 has been applied?

# swlist PHNE_36441

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: pty dropping data

Hi (again) Salvador:

Oh, I just read your last post more carefully.

Your test machine is NOT the same as the bug-reported machine.

Your test machine is 11.31 whereas the original report was for 11.11. The patch I suggested does NOT apply to 11.31.

Regards!

...JRF...
Salvador Fandino
New Member

Re: pty dropping data

James,

The tesdrive box I am using with HP-UX 11.31 has PHNE_35897 installed, and the latest STREAMS patch for this version seems to be PHNE_36574, though I don't see any reference to data lost problems in its description.

BTW, I have also posted a similar question on Perlmonks with a sample script showing the problem: http://perlmonks.org/?node_id=687727

Thanks!
James R. Ferguson
Acclaimed Contributor

Re: pty dropping data

Hi (again) Salva:

I see that you notedd, "After some investigation I have found that the operative system drops data when syswrite is called with more than 512 bytes or when consecutive enough syswrites summing up more than 512 bytes are performed."

Given that, it would helpful (at least in debugging) to report the ERRNO (Perl's $!) returned by 'syswrite'. The meanings are then documented in 'write(2)':

http://docs.hp.com/en/B2355-60127/write.2.html

http://docs.hp.com/en/B2355-60130/write.2.html

Regards!

...JRF...

Regards!

...JRF...
Salvador Fandino
New Member

Re: pty dropping data

AFAIK, errno is only updated when there is a failure, otherwise its value is meaningless. In that case syswrite (or write at the OS level) is reporting success, actually it reports that all the data is written to the pipe.

I have include the interesting truss (well, tusc) output on the Perlmonks thread.
Steven E. Protter
Exalted Contributor

Re: pty dropping data

Shalom,

The bug is so new that you might actually need to wait a few weeks for a fix to come out.

If it was recently introduced, you may be able to download and use a previous version of your CPAN module, but that of course may lead to other problems.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: pty dropping data

Hi:

> AFAIK, errno is only updated when there is a failure

Yes, 'syswrite' returns the number of bytes written or 'undef'. If 'undef' is returned, then ERRNO is available according to the documentation. Thus, I see what you are saying.

> SEP: If it was recently introduced, you may be able to download and use a previous version of your CPAN module, but that of course may lead to other problems.

Well, SEP, it just so happens that Salva *is* the maintainer of this module (as I noted in my opening post)!

Regards!

...JRF...