Changeset 1897

Show
Ignore:
Timestamp:
11/01/04 16:45:25 (19 years ago)
Author:
jalet
Message:

Added many debug messages.
Added some code to prevent short writes.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r1820 r1897  
    2424# 
    2525# $Log$ 
     26# Revision 1.75  2004/11/01 15:45:25  jalet 
     27# Added many debug messages. 
     28# Added some code to prevent short writes. 
     29# 
    2630# Revision 1.74  2004/10/13 20:51:27  jalet 
    2731# Made debugging levels be the same in cupspykota and lprngpykota. 
     
    531535        endinput = endoutput = 0 
    532536        inputclosed = outputclosed = 0 
     537        totaltochild = totalfromcups = 0 
     538        totalfromchild = totaltocups = 0 
    533539         
    534540        if self.preserveinputfile is None : 
     
    582588                                if indata : 
    583589                                    try : 
    584                                         os.write(fd, indata)     
     590                                        nbwritten = os.write(fd, indata)     
    585591                                    except (OSError, IOError), msg :     
    586592                                        self.logdebug("Error while writing to real backend's stdin %s : %s" % (fd, msg)) 
    587593                                    else :     
    588                                         indata = "" 
     594                                        if len(indata) != nbwritten : 
     595                                            self.logdebug("Short write to real backend's input !") 
     596                                        totaltochild += nbwritten     
     597                                        self.logdebug("%s bytes sent to real backend so far..." % totaltochild) 
     598                                        indata = indata[nbwritten:] 
    589599                                else :         
    590600                                    self.logdebug("No data to send to real backend yet, sleeping a bit...") 
     
    599609                                if outdata : 
    600610                                    try : 
    601                                         os.write(fd, outdata) 
     611                                        nbwritten = os.write(fd, outdata) 
    602612                                    except (OSError, IOError), msg :     
    603613                                        self.logdebug("Error while writing to CUPS back channel (stderr) %s : %s" % (fd, msg)) 
    604614                                    else : 
    605                                         outdata = "" 
     615                                        if len(outdata) != nbwritten : 
     616                                            self.logdebug("Short write to stderr (CUPS) !") 
     617                                        totaltocups += nbwritten     
     618                                        self.logdebug("%s bytes sent back to CUPS so far..." % totaltocups) 
     619                                        outdata = outdata[nbwritten:] 
    606620                                else :         
    607621                                    # self.logdebug("No data to send back to CUPS yet, sleeping a bit...") # Uncommenting this fills your logs 
     
    629643                                    else :     
    630644                                        indata += data 
     645                                        totalfromcups += len(data) 
     646                                        self.logdebug("%s bytes read from CUPS so far..." % totalfromcups) 
    631647                                elif fd == fromcfno : 
    632648                                    if not data : 
     
    635651                                    else : 
    636652                                        outdata += data 
     653                                        totalfromchild += len(data) 
     654                                        self.logdebug("%s bytes read from real backend so far..." % totalfromchild) 
    637655                                else :     
    638656                                    self.logdebug("Unexpected : %s - Sleeping a bit..." % self.formatFileEvent(fd, mask)) 
     
    669687         
    670688        self.logdebug("Exiting streams polling loop...") 
     689         
     690        self.logdebug("input data's final length : %s" % len(indata)) 
     691        self.logdebug("back-channel data's final length : %s" % len(outdata)) 
     692         
     693        self.logdebug("Total bytes read from CUPS (job's datas) : %s" % totalfromcups) 
     694        self.logdebug("Total bytes sent to real backend (job's datas) : %s" % totaltochild) 
     695         
     696        self.logdebug("Total bytes read from real backend (back-channel datas) : %s" % totalfromchild) 
     697        self.logdebug("Total bytes sent back to CUPS (back-channel datas) : %s" % totaltocups) 
    671698         
    672699        # Check exit code of original CUPS backend.