[asterisk-bugs] [DAHDI-linux 0018760]: [patch] inconsistent read from /proc/dahdi if size changes

Asterisk Bug Tracker noreply at bugs.digium.com
Mon Feb 7 09:29:55 CST 2011


The following issue has been UPDATED. 
====================================================================== 
https://issues.asterisk.org/view.php?id=18760 
====================================================================== 
Reported By:                tzafrir
Assigned To:                
====================================================================== 
Project:                    DAHDI-linux
Issue ID:                   18760
Category:                   General
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
JIRA:                        
Reviewboard Link:            
====================================================================== 
Date Submitted:             2011-02-07 09:29 CST
Last Modified:              2011-02-07 09:29 CST
====================================================================== 
Summary:                    [patch] inconsistent read from /proc/dahdi if size
changes
Description: 
Reading from a file should be done in a loop, testing for extra output.
If at the time of this read loop the "size" of /proc/dahdi/N increases,
you get extra output.

I have applied the attached patch, which simulates such a change by adding
some extra text (" CHEATING") to each line.

The effect:
# cat /proc/dahdi/1
Span 1: XBUS-00/XPD-00 "Xorcom XPD https://issues.asterisk.org/view.php?id=0/00:
BRI_NT"

           1 XPP_BRI_NT/00/00/0
           2 XPP_BRI_NT/00/00/1
           3 XPP_BRI_NT/00/00/2
P_BRI_NT/00/00/2  CHEATING

# cat /proc/dahdi/9
Span 9: XBUS-00/XPD-10 "Xorcom XPD https://issues.asterisk.org/view.php?id=0/10:
FXS" (MASTER)

          25 XPP_FXS/00/10/0
          26 XPP_FXS/00/10/1
          27 XPP_FXS/00/10/2
          28 XPP_FXS/00/10/3
          29 XPP_FXS/00/10/4
          30 XPP_FXS/00/10/5
          31 XPP_FXS/00/10/6
          32 XPP_FXS/00/10/7
HEATING
          31 XPP_FXS/00/10/6  CHEATING
          32 XPP_FXS/00/10/7  CHEATING

# strace -eread cat /proc/dahdi/1 >/dev/null
read(3,
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260e\1\0004\0\0\0\4"...,
512) = 512
read(3, "Span 1: XBUS-00/XPD-00 \"Xorcom XP"..., 4096) = 131
read(3, "P_BRI_NT/00/00/2  CHEATING\n"..., 4096) = 27
read(3, ""..., 4096)                    = 0

# strace -eread cat /proc/dahdi/9 >/dev/null
read(3,
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260e\1\0004\0\0\0\4"...,
512) = 512
read(3, "Span 9: XBUS-00/XPD-10 \"Xorcom XP"..., 4096) = 243
read(3, "HEATING\n\t  31 XPP_FXS/00/10/6  CH"..., 4096) = 72
read(3, ""..., 4096)                    = 0

We would have expected the second read to return 0. But setting 'eof=1'
does not provide this desired effect.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-02-07 09:29 tzafrir        Summary                  inconsistent read from
/proc/dahdi if size changes => [patch] inconsistent read from /proc/dahdi if
size changes
======================================================================




More information about the asterisk-bugs mailing list