|
|
| version 1.3, 2001/03/08 17:52:41 | version 1.4, 2007/08/08 07:54:05 |
|---|---|
| Line 1171 finish_responding( | Line 1171 finish_responding( |
| { | { |
| int error = 0; | int error = 0; |
| u_int nbytes, ntokens = 0, ret_ntokens, i; | u_int nbytes, ntokens = 0, ret_ntokens, i; |
| dm_token_t *tokenbuf = NULL; | dm_token_t *tokenbuf = NULL, *tokenptr; |
| size_t buflen, ret_buflen; | size_t buflen, ret_buflen; |
| char *msgbuf = NULL; | char *msgbuf = NULL; |
| dm_eventmsg_t *msg; | dm_eventmsg_t *msg; |
| Line 1193 finish_responding( | Line 1193 finish_responding( |
| * If we're already using the returned size, double it and try again. | * If we're already using the returned size, double it and try again. |
| */ | */ |
| do { | do { |
| dm_token_t *tmpbuf; | |
| ntokens = (ntokens != ret_ntokens) ? ret_ntokens : ntokens*2; | ntokens = (ntokens != ret_ntokens) ? ret_ntokens : ntokens*2; |
| nbytes = ntokens * (sizeof(dm_token_t) + sizeof(dm_vardata_t)); | nbytes = ntokens * (sizeof(dm_token_t) + sizeof(dm_vardata_t)); |
| tokenbuf = malloc(nbytes); | tmpbuf = realloc(tokenbuf, nbytes); |
| if (tokenbuf == NULL) { | if (tmpbuf == NULL) { |
| err_msg("Can't malloc %d bytes for tokenbuf\n", nbytes); | err_msg("Can't malloc %d bytes for tokenbuf\n", nbytes); |
| error = 1; | error = 1; |
| goto out; | goto out; |
| } | } |
| tokenbuf = tmpbuf; | |
| error = dm_getall_tokens(sid, ntokens, tokenbuf, &ret_ntokens); | error = dm_getall_tokens(sid, ntokens, tokenbuf, &ret_ntokens); |
| } while (error && errno == E2BIG); | } while (error && errno == E2BIG); |
| Line 1209 finish_responding( | Line 1211 finish_responding( |
| goto out; | goto out; |
| } | } |
| tokenptr = tokenbuf; | |
| for (i = 0; i < ret_ntokens; i++) { | for (i = 0; i < ret_ntokens; i++) { |
| if (Verbose) | if (Verbose) |
| err_msg("Responding to outstanding event for token %d\n",(int)*tokenbuf); | err_msg("Responding to outstanding event for token %d\n",(int)*tokenptr); |
| /* | /* |
| * The E2BIG dance reprise... | * The E2BIG dance reprise... |
| */ | */ |
| do { | do { |
| char *tmpbuf; | |
| buflen = (buflen != ret_buflen) ? ret_buflen : buflen * 2; | buflen = (buflen != ret_buflen) ? ret_buflen : buflen * 2; |
| msgbuf = malloc(buflen); | tmpbuf = realloc(msgbuf, buflen); |
| if (msgbuf == NULL) { | if (tmpbuf == NULL) { |
| err_msg("Can't malloc %d bytes for msgbuf\n", buflen); | err_msg("Can't malloc %d bytes for msgbuf\n", buflen); |
| error = 1; | error = 1; |
| goto out; | goto out; |
| } | } |
| error = dm_find_eventmsg(sid, *tokenbuf, buflen, msgbuf, &ret_buflen); | msgbuf = tmpbuf; |
| error = dm_find_eventmsg(sid, *tokenptr, buflen, msgbuf, &ret_buflen); | |
| } while (error && errno == E2BIG); | } while (error && errno == E2BIG); |
| if (error) { | if (error) { |
| errno_msg("Can't find the event message for token %d", (int)*tokenbuf); | errno_msg("Can't find the event message for token %d", (int)*tokenptr); |
| goto out; | goto out; |
| } | } |
| Line 1239 finish_responding( | Line 1244 finish_responding( |
| msg = DM_STEP_TO_NEXT(msg, dm_eventmsg_t *); | msg = DM_STEP_TO_NEXT(msg, dm_eventmsg_t *); |
| } | } |
| tokenbuf++; | tokenptr++; |
| } | } |
| out: | out: |