Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Problem with Threaded Socket Server

by BrowserUk (Pope)
on Aug 18, 2013 at 21:04 UTC ( #1049953=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Problem with Threaded Socket Server
in thread Problem with Threaded Socket Server

Just saw your update:

So the idea is to create a new Device::SerialPort class which inherits the original class and overrides the destructor, right?

That is the essence of the first of the two possibilities I offered. And you could go the full subclassing route if that's your thing. Personally, I wouldn't.

I'd just inject my override directly into the D::SP namespace. Ie. At the top of your program somewhere after you've used Device::SerialPort, define a subroutine:

sub Device::SerialPort::DESTROY { my $self = shift; return unless (defined $self->{NAME}); if ($self->{"_DEBUG"}) { carp "Destroying $self->{NAME}"; } #$self->close; }

You'll get a "subroutine redefined" warning -- which you can disable -- but the affect will be the same as 'doing it properly' without the hassle.

Simply commenting out the #$self->close; may be enough. If not, then you will either have to investigate why not; or try my second suggestion.

Don't forget to call close() in the same thread as you created the USB connection before finishing.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^3: Problem with Threaded Socket Server
Select or Download Code
Re^4: Problem with Threaded Socket Server
by piece (Novice) on Aug 18, 2013 at 21:29 UTC
    Ok, tried it properly with a new class which inherits DEVICE::SerialPort and the direct way above. Both have the same effect:
    *** Error in `/usr/bin/perl': corrupted double-linked list: 0x00000000 +0173d840 ***
    or
    Segmentation fault (core dumped)

    The error messages differ on the crashes. Seems the garbage collection still wants to clean up something and messes it up.

    Found this. Sadly i don't understand it and don't know if this may be of any help.

    Tomorrow i'll try your second suggestion. Thx alot so far.
      Both have the same effect: *** Error in `/usr/bin/perl': corrupted double-linked list: 0x000000000173d840 *** or Segmentation fault (core dumped)

      It was a long shot at best. As I don't do *nix, there is no way for me to investigate those errors further. They do not seem to originate in the Device::SerialPort code.

      Found this. Sadly i don't understand it and don't know if this may be of any help.

      No. It won't help.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1049953]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2015-07-07 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls