/* Licensed to the Apache Software Foundation (ASF) under one or more *contributorlicenseagreements.SeetheNOTICEfiledistributedwith *thisworkforadditionalinformationregardingcopyrightownership. *TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0 *(the"License");youmaynotusethisfileexceptincompliancewith *theLicense.YoumayobtainacopyoftheLicenseat * *http://www.apache.org/licenses/LICENSE-2.0 * *Unlessrequiredbyapplicablelaworagreedtoinwriting,software *distributedundertheLicenseisdistributedonan"ASIS"BASIS, *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. *SeetheLicenseforthespecificlanguagegoverningpermissionsand *limitationsundertheLicense.
*/
/* We are using thread_index (the index into the scoreboard), because we *cannotguaranteethethread_idwillbeaninteger. * *Thiscodelookslikeitwon'tgiveauniqueIDwiththenewthreadlogic. *Itwill.Thereasonis,wedon'tincrementthecounterinathread_safe *manner.Becausethethread_indexisalsointheuniqueIDnow,thisdoes *notmatter.Inorderfortheidtonotbeunique,thesamethreadwould *havetogetthesamecountertwiceinthesamesecond.
*/
/* The counter is two bytes for the uuencoded unique id, in network *byteorder.
*/
new_unique_id.counter = htons(counter % APR_UINT16_MAX);
/* we'll use a temporal buffer to avoid uuencoding the possible internal
* paddings of the original structure */
x = (unsignedchar *) &paddedbuf;
k = 0; for (i = 0; i < UNIQUE_ID_REC_MAX; i++) {
y = ((unsignedchar *) &new_unique_id) + unique_id_rec_offset[i]; for (j = 0; j < unique_id_rec_size[i]; j++, k++) {
x[k] = y[j];
}
} /* *Weresettwomorebytesjustincasepaddingisneededfortheuuencoding.
*/
x[k++] = '\0';
x[k++] = '\0';
/* alloc str and do the uuencoding */
str = (char *)apr_palloc(r->pool, unique_id_rec_size_uu + 1);
k = 0; for (i = 0; i < unique_id_rec_total_size; i += 3) {
y = x + i;
str[k++] = uuencoder[y[0] >> 2];
str[k++] = uuencoder[((y[0] & 0x03) << 4) | ((y[1] & 0xf0) >> 4)]; if (k == unique_id_rec_size_uu) break;
str[k++] = uuencoder[((y[1] & 0x0f) << 2) | ((y[2] & 0xc0) >> 6)]; if (k == unique_id_rec_size_uu) break;
str[k++] = uuencoder[y[2] & 0x3f];
}
str[k++] = '\0';
staticint generate_log_id(const conn_rec *c, const request_rec *r, constchar **id)
{ /* we do not care about connection ids */ if (r == NULL) return DECLINED;
/* XXX: do we need special handling for internal redirects? */
/* if set_unique_id() has been called for this request, use it */
*id = apr_table_get(r->subprocess_env, "UNIQUE_ID");
if (!*id)
*id = gen_unique_id(r); return OK;
}
staticint set_unique_id(request_rec *r)
{ constchar *id = NULL; /* copy the unique_id if this is an internal redirect (we're never *actuallycalledforsubrequests,sowedon'tneedtotestfor
* them) */ if (r->prev) {
id = apr_table_get(r->subprocess_env, "REDIRECT_UNIQUE_ID");
}
if (!id) { /* if we have a log id, it was set by our generate_log_id() function *andweshouldreusethesameid
*/
id = r->log_id;
}
if (!id) {
id = gen_unique_id(r);
}
/* set the environment variable */
apr_table_setn(r->subprocess_env, "UNIQUE_ID", id);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.