Bug 2507 - ConfigStore RawTextConfigLoad doesn't reset stream error state
ConfigStore RawTextConfigLoad doesn't reset stream error state
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: config-store
ns-3-dev
All All
: P5 major
Assigned To: Peter Barnes
:
: 2508 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-09-21 14:13 EDT by Peter Barnes
Modified: 2016-09-27 19:54 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (446 bytes, text/x-diff)
2016-09-21 14:17 EDT, Peter Barnes
Details
test program (1.09 KB, text/x-c++src)
2016-09-21 14:17 EDT, Peter Barnes
Details
input file for test program (102 bytes, text/plain)
2016-09-21 14:18 EDT, Peter Barnes
Details
Revised test program (1.38 KB, patch)
2016-09-21 16:08 EDT, Peter Barnes
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Barnes 2016-09-21 14:13:21 EDT
From Robert Schmidt via the users' list:

Hi all, 

I have problems using the ConfigStore. I guess it is a bug, but maybe I 
am using it wrong. I am on ns3-dev. 

The problem occurs when trying to configure my model via 
ConfigStore::ConfigureAttributes () after having called 
ConfigStore::ConfigureDefaults () as explained here [1]. I attached a 
sample script that illustrates this, config-test.cc (it is based on 
first.cc from the tutorial, I did not manage to produce an easier one). 
When running the script without setting any parameters, the server pings 
three times back (enable the UdpEchoServerApplication logging component). 

Now, via a config in raw mode I set the StartTime of the UdpEchoClient 
to two seconds. I'd expect that the server starts to respond from 2s 
onwards. This is not the case. 

By setting the RawTextConfig logging component one can see that upon 
calling RawTextConfigLoad::Attributes (), nothing happens. Indeed the 
reset of the file error flags is not called like in 
RawTextConfigLoad::Default (). By adding m_is->clear (); to the begging 
of RawTextConfigLoad::Attributes () it parses the file correctly and the 
UdpEchoClient behaves correctly. 

Is this a real bug or am I missing something? I attached a patch adding 
this one line. 

Robert 

[1] https://www.nsnam.org/wiki/HOWTO_use_the_ConfigStore
Comment 1 Peter Barnes 2016-09-21 14:17:23 EDT
Created attachment 2586 [details]
Proposed patch
Comment 2 Peter Barnes 2016-09-21 14:17:44 EDT
Created attachment 2587 [details]
test program
Comment 3 Peter Barnes 2016-09-21 14:18:08 EDT
Created attachment 2588 [details]
input file for test program
Comment 4 Peter Barnes 2016-09-21 16:08:08 EDT
Created attachment 2589 [details]
Revised test program

Revised test program to simplify invocation:

- set ConfigStore defaults

- turn on logging for UdpEchoServerApplication

./waf --run config-test
Comment 5 Tommaso Pecorella 2016-09-21 17:48:18 EDT
*** Bug 2508 has been marked as a duplicate of this bug. ***
Comment 6 Tommaso Pecorella 2016-09-22 04:44:38 EDT
(In reply to Tommaso Pecorella from comment #5)
> *** Bug 2508 has been marked as a duplicate of this bug. ***

In my opinion this could be safely pushed.

I'd also say to indicate Robert Schmidt <rschmi@gmx.net> as the patch author.
Comment 7 Peter Barnes 2016-09-22 12:45:18 EDT
Wrt

> Since seekg(0) doesn't clear the eof bit (in c++99, in c++11 it does)

Since we have --std=c++11 I'm puzzled why this cropped up at all?
Comment 8 Tommaso Pecorella 2016-09-22 19:51:28 EDT
Well, according to http://www.cplusplus.com/reference/istream/istream/seekg/ it should.
Perhaps some compilers aren't yet very pedantic about these small details.

(In reply to Peter Barnes from comment #7)
> Wrt
> 
> > Since seekg(0) doesn't clear the eof bit (in c++99, in c++11 it does)
> 
> Since we have --std=c++11 I'm puzzled why this cropped up at all?
Comment 9 Peter Barnes 2016-09-27 19:45:25 EDT
Pushed in 12337 e37de7f82ed2