--- vcl/unx/generic/printer/cupsmgr.cxx.orig 2012-09-25 16:13:30.000000000 +0400 +++ vcl/unx/generic/printer/cupsmgr.cxx 2012-12-13 12:12:52.686296375 +0400 @@ -73,6 +73,7 @@ const char* (*m_pcupsUser)(); void (*m_pcupsSetUser)(const char*); const char* (*m_pcupsGetOption)(const char*,int,cups_option_t*); + void (*m_pcupsSetServer)(const char*); oslGenericFunction loadSymbol( const char* ); public: @@ -95,7 +96,19 @@ const char* pTitle, int nOptions, cups_option_t* pOptions ) - { return m_pcupsPrintFile( pPrinter, pFileName, pTitle, nOptions, pOptions ); } + { + int job_id = m_pcupsPrintFile( pPrinter, pFileName, pTitle, nOptions, pOptions ); + if (job_id == 0 && m_pcupsSetServer != NULL) { + /* + * Fail could be due to expired HTTP connection + * calling SetServer resets internal connection, so that next CUPS call reconnects + */ + m_pcupsSetServer(NULL); + job_id = m_pcupsPrintFile( pPrinter, pFileName, pTitle, nOptions, pOptions ); + // fprintf(stderr, "-- cupsPrintFile: retry rc=%i\n", job_id); + } + return job_id; + } rtl::OString cupsGetPPD( const char* pPrinter ); @@ -226,6 +239,8 @@ loadSymbol( "cupsSetUser" ); m_pcupsGetOption = (const char*(*)(const char*,int,cups_option_t*)) loadSymbol( "cupsGetOption" ); + m_pcupsSetServer = (void(*)(const char*)) + loadSymbol( "cupsSetServer" ); if( ! ( m_pcupsPrintFile &&