c++ - Why am I getting a bps_remove_fd failure when trying to store a QSslSocket inside a QScopedPointer? -


i developing networking-based app blackberry playbook using qt4.8.3, part of involves storing qabstractsocket in qscopedpointer follows:

qscopedpointer<qabstractsocket> nntp; 

in implementation, store either qsslsocket or qtcpsocket (both of inherit qabstractsocket) depending on whether conenction encrypted, i.e.,

if(ssl) {     nntp.reset(new qsslsocket(this));     (dynamic_cast<qsslsocket*>(nntp.data())))->connecttohostencrypted(server, port); } else {     nntp.reset(new qtcpsocket(this));     nntp->connecttohost(server, port); } 

when going down ssl route (non-ssl works fine!), end following run time error:

virtual void qeventdispatcherblackberry::unregistersocketnotifier(qsocketnotifier*) bps_remove_fd() failed 19

the error blackberry related given error description , fact code works expected on other platforms (tested on mac , linux). (note, number 19 refers file descriptor).

any ideas why seeing error , how can fix it?

thanks,

ben.

edit: i've realised instead of using pointer, can have single qsslsocket , treat regular qtcpsocket when in non-ssl mode. far easier. still know reason above error however

we can have @ the source code in order see happening. source code of unregistersocketnotifier is:

void qeventdispatcherblackberry::unregistersocketnotifier(qsocketnotifier *notifier) {     // unregister fd bps     int sockfd = notifier->socket();     int result = bps_remove_fd(sockfd);     if (result != bps_success)         qwarning() << q_func_info << "bps_remove_fd() failed";      // allow base unix implementation unregister fd     qeventdispatcherunix::unregistersocketnotifier(notifier); } 

and correlation bps_remove_fd documentation says:

if file descriptor present removed channel. io_handler callback , associated user data removed.

[returns] bps_success if fd (file descriptor) removed channel, bps_failure errno value set otherwise.

the clues make bps_remove_fd fail possibility fd not present, mean socket not have valid file descriptor. other error whichever reason not specified, file exists not removed.

the variable errno should set, may have more complete error description if @ - did not try though, don't have takes -.

i bet bps_remove_fd works on same principle posix's close(int fd), had @ close's documentation see cause failure. states shall/may fail in following cases:

  • the argument not valid file descriptor (shall fail).
  • close may interrupted signal (shall fail).
  • an i/o error occurred while reading or writing file system (may fail).

i have made answer comment since not answer question in particular case, hope may @ least understand what's going on little bit more :)


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -