DIRACGrid/DIRAC — pull request #552 by graciani (2012-02-29 12:50:53+00:00)
Title: FIX: protect LFC client from getting None in lfc.lfc_readdirxr( oDirectory, "" ) 

In some rare cases we reach the end of oDirectory, before nbfiles iterations

This was crashing CTA client when listing the top directory.

the following python code shows the problem:

import os
import lfc
os.environ['LFC_HOST'] = 'lfc-egee.in2p3.fr'
path = '/grid/vo.cta.in2p3.fr'
print 'Path:', path
fstat = lfc.lfc_filestatg()
value = lfc.lfc_statg( path, '', fstat )
if value != 0:
print 'Error', lfc.sstrerror( lfc.cvar.serrno )

print 'Number of entries:', fstat.nlink
directory = lfc.lfc_opendirg( path, '')
if not directory:
print 'Error', lfc.sstrerror( lfc.cvar.serrno )
counter = 0
while True:
value = lfc.lfc_readdirxr( directory, "" )
if value:
counter += 1
else:
if lfc.cvar.serrno:
print 'Error', lfc.sstrerror( lfc.cvar.serrno )
break

print 'Items:', counter