Reputation: 1223
I want to build a simple Tool to check for SVN revision number changes ( = someone committed), but I'm stuck at a very strange issue. When I compile and run my code, the first of the following messages gets printed, the next doesn't:
while (true) {
var msg = new Soup.Message("GET", this.repo.URL);
session.send_message(msg);
MatchInfo matchInfo;
pattern.match((string)msg.response_body.data, 0, out matchInfo);
var revisionString = matchInfo.fetch_named("revision");
stdout.printf("Current Revision: [%s]\n", revisionString);
var currentRevision = int.parse("383");
stdout.printf("Current Revision parsed %d", currentRevision);
Thread.usleep(150000000);
}
I inserted the hardcoded string "383"
just for testing, but it still fails.
I can't see anything wrong with the printf's either, and there are no compiler errors.
If it would help, I could post some more code.
Upvotes: 1
Views: 219
Reputation: 7153
int.parse
just calls atoi
. You can verify this by looking at the generated C.
atoi
is not thread-safe and I'm assuming you're running this in multiple threads due to your Thread.usleep
.
Use int64.try_parse
instead, which is based on strtoll
.
Also, try a more minimal test case not involving the this.repo.LastRevision
.
Upvotes: 1