mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 07:30:12 +01:00
refactoring
This commit is contained in:
parent
f17e50d3a7
commit
b05ddbf571
@ -19,8 +19,8 @@ int string_parser(char *src, char *target, int limit){
|
|||||||
|
|
||||||
int multi_line_string_parser(char *src, char *target, int limit){
|
int multi_line_string_parser(char *src, char *target, int limit){
|
||||||
if(strlen(src) > 0 && strlen(target) + strlen(src) + 3 < limit){
|
if(strlen(src) > 0 && strlen(target) + strlen(src) + 3 < limit){
|
||||||
strncat(target, src, limit);
|
strncat(target, src, limit-strlen(target));
|
||||||
strncat(target, "\r\n", limit);
|
strncat(target, "\r\n", limit-strlen(target));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -225,8 +225,8 @@ int memcached_add(struct memcached_server *ptr, char *key, unsigned int keylen,
|
|||||||
snprintf(ptr->buf, MAXBUFSIZE-1, "add %s %d %ld %d \r\n", key, flags, expiry, valuelen);
|
snprintf(ptr->buf, MAXBUFSIZE-1, "add %s %d %ld %d \r\n", key, flags, expiry, valuelen);
|
||||||
len = strlen(ptr->buf);
|
len = strlen(ptr->buf);
|
||||||
|
|
||||||
strncat(ptr->buf, value, MAXBUFSIZE-1);
|
strncat(ptr->buf, value, MAXBUFSIZE-strlen(ptr->buf)-1);
|
||||||
strncat(ptr->buf, "\r\n", MAXBUFSIZE-1);
|
strncat(ptr->buf, "\r\n", MAXBUFSIZE-strlen(ptr->buf)-1);
|
||||||
|
|
||||||
len += valuelen + 2;
|
len += valuelen + 2;
|
||||||
|
|
||||||
@ -248,8 +248,8 @@ int memcached_set(struct memcached_server *ptr, char *key, unsigned int keylen,
|
|||||||
snprintf(ptr->buf, MAXBUFSIZE-1, "set %s %d %ld %d \r\n", key, flags, expiry, valuelen);
|
snprintf(ptr->buf, MAXBUFSIZE-1, "set %s %d %ld %d \r\n", key, flags, expiry, valuelen);
|
||||||
len = strlen(ptr->buf);
|
len = strlen(ptr->buf);
|
||||||
|
|
||||||
strncat(ptr->buf, value, MAXBUFSIZE-1);
|
strncat(ptr->buf, value, MAXBUFSIZE-strlen(ptr->buf)-1);
|
||||||
strncat(ptr->buf, "\r\n", MAXBUFSIZE-1);
|
strncat(ptr->buf, "\r\n", MAXBUFSIZE-strlen(ptr->buf)-1);
|
||||||
|
|
||||||
len += valuelen + 2;
|
len += valuelen + 2;
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata
|
|||||||
if(strncmp(buf, "Subject:", strlen("Subject:")) == 0) p += strlen("Subject:");
|
if(strncmp(buf, "Subject:", strlen("Subject:")) == 0) p += strlen("Subject:");
|
||||||
if(*p == ' ') p++;
|
if(*p == ' ') p++;
|
||||||
|
|
||||||
strncat(state->b_subject, p, MAXBUFSIZE-1);
|
strncat(state->b_subject, p, MAXBUFSIZE-strlen(state->b_subject)-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata
|
|||||||
while(isspace(*p)) p++;
|
while(isspace(*p)) p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncat(state->b_subject, p, MAXBUFSIZE-1);
|
strncat(state->b_subject, p, MAXBUFSIZE-strlen(state->b_subject)-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,6 @@ static void takesig(int sig){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
case SIGKILL:
|
|
||||||
quit = 1;
|
quit = 1;
|
||||||
p_clean_exit();
|
p_clean_exit();
|
||||||
break;
|
break;
|
||||||
@ -246,10 +245,9 @@ void p_clean_exit(){
|
|||||||
if(data.dedup != MAP_FAILED) munmap(data.dedup, MAXCHILDREN*DIGEST_LENGTH*2);
|
if(data.dedup != MAP_FAILED) munmap(data.dedup, MAXCHILDREN*DIGEST_LENGTH*2);
|
||||||
|
|
||||||
#ifdef HAVE_STARTTLS
|
#ifdef HAVE_STARTTLS
|
||||||
if(data.ctx){
|
if(data.ctx) SSL_CTX_free(data.ctx);
|
||||||
SSL_CTX_free(data.ctx);
|
|
||||||
ERR_free_strings();
|
ERR_free_strings();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -463,7 +461,6 @@ int main(int argc, char **argv){
|
|||||||
|
|
||||||
set_signal_handler(SIGCHLD, takesig);
|
set_signal_handler(SIGCHLD, takesig);
|
||||||
set_signal_handler(SIGTERM, takesig);
|
set_signal_handler(SIGTERM, takesig);
|
||||||
set_signal_handler(SIGKILL, takesig);
|
|
||||||
set_signal_handler(SIGHUP, takesig);
|
set_signal_handler(SIGHUP, takesig);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user