Mercurial > noffle
comparison src/protocol.c @ 221:0eaf93997170 noffle
[svn] generate MessageID with pid and index number, not with random number.
| author | mirkol |
|---|---|
| date | Sun, 02 Dec 2001 19:32:44 +0000 |
| parents | 24d4cd032da5 |
| children | 4e69e9b722ae |
comparison
equal
deleted
inserted
replaced
| 220:81277bc2c264 | 221:0eaf93997170 |
|---|---|
| 1 /* | 1 /* |
| 2 protocol.c | 2 protocol.c |
| 3 | 3 |
| 4 $Id: protocol.c 316 2001-10-31 11:44:53Z bears $ | 4 $Id: protocol.c 340 2001-12-02 19:32:44Z mirkol $ |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #if HAVE_CONFIG_H | 7 #if HAVE_CONFIG_H |
| 8 #include <config.h> | 8 #include <config.h> |
| 9 #endif | 9 #endif |
| 305 void | 305 void |
| 306 Prt_genMsgId( Str msgId, const char *from, const char *suffix ) | 306 Prt_genMsgId( Str msgId, const char *from, const char *suffix ) |
| 307 { | 307 { |
| 308 Str domain, date; | 308 Str domain, date; |
| 309 time_t t; | 309 time_t t; |
| 310 static Bool randSeeded = FALSE; | 310 static long count = 0; |
| 311 | 311 |
| 312 if ( ! randSeeded ) | |
| 313 { | |
| 314 struct timeval tv; | |
| 315 struct timezone tz; | |
| 316 | |
| 317 if ( gettimeofday( &tv, &tz ) == 0 ) | |
| 318 srand( (unsigned int) tv.tv_usec ); | |
| 319 randSeeded = TRUE; | |
| 320 } | |
| 321 getDomain( domain, from ); | 312 getDomain( domain, from ); |
| 322 time( &t ); | 313 time( &t ); |
| 323 strftime( date, MAXCHAR, "%Y%m%d%H%M%S", gmtime( &t ) ); | 314 strftime( date, MAXCHAR, "%Y%m%d%H%M%S", gmtime( &t ) ); |
| 324 snprintf( msgId, MAXCHAR, "<%s.%X.%s@%s>", date, rand(), suffix, domain ); | 315 snprintf( msgId, MAXCHAR, "<%s.%X.%lx.%s@%s>", date, getpid(), count++ ,suffix, domain ); |
| 325 ASSERT( Prt_isValidMsgId( msgId ) ); | 316 ASSERT( Prt_isValidMsgId( msgId ) ); |
| 326 } | 317 } |
| 327 | 318 |
| 328 void | 319 void |
| 329 Prt_genPathHdr( Str pathHdr, const char *from ) | 320 Prt_genPathHdr( Str pathHdr, const char *from ) |
