From: Braden M. <br...@us...> - 2006-12-02 07:20:22
|
Update of /cvsroot/openvrml/openvrml/src/openvrml-gtkplug In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv18013/src/openvrml-gtkplug Modified Files: gtkvrmlbrowser.cpp main.cpp plugin_streambuf.cpp plugin_streambuf.h Log Message: Mark any uninitialized plugin_streambufs as failed when quitting openvrml-gtkplug so that reader threads will not continue to block on them (creating a deadlock). Index: plugin_streambuf.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/openvrml-gtkplug/plugin_streambuf.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** plugin_streambuf.cpp 1 Oct 2006 05:47:07 -0000 1.2 --- plugin_streambuf.cpp 2 Dec 2006 07:20:21 -0000 1.3 *************** *** 62,65 **** --- 62,68 ---- const std::string & type) { + g_assert(stream_id); + g_assert(!received_url.empty()); + g_assert(!type.empty()); boost::mutex::scoped_lock lock(this->mutex_); bool succeeded = uninitialized_plugin_streambuf_map_.erase(this->url_); *************** *** 72,76 **** .second; g_assert(succeeded); ! this->streambuf_initialized_.notify_all(); } --- 75,89 ---- .second; g_assert(succeeded); ! this->streambuf_initialized_or_failed_.notify_all(); ! } ! ! void openvrml_player::plugin_streambuf::fail() ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! const bool succeeded = ! uninitialized_plugin_streambuf_map_.erase(this->url_); ! g_assert(succeeded); ! this->buf_.set_eof(); ! this->streambuf_initialized_or_failed_.notify_all(); } *************** *** 79,83 **** boost::mutex::scoped_lock lock(this->mutex_); while (!this->initialized_) { ! this->streambuf_initialized_.wait(lock); } return this->url_; --- 92,96 ---- boost::mutex::scoped_lock lock(this->mutex_); while (!this->initialized_) { ! this->streambuf_initialized_or_failed_.wait(lock); } return this->url_; *************** *** 88,92 **** boost::mutex::scoped_lock lock(this->mutex_); while (!this->initialized_) { ! this->streambuf_initialized_.wait(lock); } return this->type_; --- 101,105 ---- boost::mutex::scoped_lock lock(this->mutex_); while (!this->initialized_) { ! this->streambuf_initialized_or_failed_.wait(lock); } return this->type_; *************** *** 108,112 **** boost::mutex::scoped_lock lock(this->mutex_); while (!this->initialized_) { ! this->streambuf_initialized_.wait(lock); } --- 121,125 ---- boost::mutex::scoped_lock lock(this->mutex_); while (!this->initialized_) { ! this->streambuf_initialized_or_failed_.wait(lock); } *************** *** 176,179 **** --- 189,198 ---- } + bool openvrml_player::uninitialized_plugin_streambuf_map::empty() const + { + boost::mutex::scoped_lock lock(this->mutex_); + return this->map_.empty(); + } + const boost::shared_ptr<openvrml_player::plugin_streambuf> openvrml_player::uninitialized_plugin_streambuf_map::front() const Index: main.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/openvrml-gtkplug/main.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** main.cpp 30 Nov 2006 06:47:43 -0000 1.5 --- main.cpp 2 Dec 2006 07:20:21 -0000 1.6 *************** *** 145,148 **** --- 145,158 ---- // Got EOF from the command stream. Time to shut down. // + // First, mark any outstanding uninitialized streams as failed so + // that another thread doesn't block waiting for them. + // + while (!uninitialized_plugin_streambuf_map_.empty()) { + uninitialized_plugin_streambuf_map_.front()->fail(); + } + + // + // Set the quit flag. + // ::quit_flag.value(true); Index: gtkvrmlbrowser.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/openvrml-gtkplug/gtkvrmlbrowser.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gtkvrmlbrowser.cpp 22 Nov 2006 00:05:19 -0000 1.3 --- gtkvrmlbrowser.cpp 2 Dec 2006 07:20:21 -0000 1.4 *************** *** 484,489 **** class plugin_resource_istream : public openvrml::resource_istream { ! boost::shared_ptr<plugin_streambuf> streambuf_; ! GIOChannel * request_channel_; public: --- 484,489 ---- class plugin_resource_istream : public openvrml::resource_istream { ! const boost::shared_ptr<plugin_streambuf> streambuf_; ! GIOChannel * const request_channel_; public: *************** *** 512,516 **** // ! // This blocks until we know the result of NPN_GetURL. // const int get_url_result = this->streambuf_->get_url_result(); --- 512,516 ---- // ! // This blocks until we receive a get-url-result command. // const int get_url_result = this->streambuf_->get_url_result(); Index: plugin_streambuf.h =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/openvrml-gtkplug/plugin_streambuf.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** plugin_streambuf.h 1 Oct 2006 05:47:07 -0000 1.2 --- plugin_streambuf.h 2 Dec 2006 07:20:21 -0000 1.3 *************** *** 43,47 **** mutable boost::condition received_get_url_result_; bool initialized_; ! mutable boost::condition streambuf_initialized_; std::string url_; std::string type_; --- 43,47 ---- mutable boost::condition received_get_url_result_; bool initialized_; ! mutable boost::condition streambuf_initialized_or_failed_; std::string url_; std::string type_; *************** *** 60,63 **** --- 60,64 ---- const std::string & received_url, const std::string & type); + void fail(); const std::string & url() const; const std::string & type() const; *************** *** 78,81 **** --- 79,83 ---- bool erase(const std::string & url); size_t size() const; + bool empty() const; const boost::shared_ptr<plugin_streambuf> front() const; } uninitialized_plugin_streambuf_map_; |