Skip to content

Commit

Permalink
fix in webserver
Browse files Browse the repository at this point in the history
  • Loading branch information
on4akh committed May 10, 2014
1 parent a078b91 commit ab13f2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions master_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>

struct repeater{
struct sockaddr_in address;
Expand Down
7 changes: 3 additions & 4 deletions webserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ void *webServerListener(){
struct sockaddr_in servaddr;
int yes=1; // for setsockopt() SO_REUSEADDR, below
pthread_t thread;

/* Create socket */

if ( (listener = socket(AF_INET, SOCK_STREAM, 0)) < 0 ){
Expand All @@ -58,7 +57,7 @@ void *webServerListener(){
}

/* Populate socket address structure */

memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = inet_addr("0.0.0.0");
Expand Down Expand Up @@ -381,7 +380,7 @@ int Return_Resource(int conn, FILE *resource, struct ReqInfo * reqinfo) {
if (strstr(reqinfo->resource,".html")){
while(fgets(line,sizeof(line),resource)){
sprintf(sendLine,"%s",htmlReplace(line,reqinfo->resource));
if ( write(conn, sendLine, strlen(sendLine)) < 1 ){
if ( send(conn, sendLine, strlen(sendLine),MSG_NOSIGNAL) < 1 ){
syslog(LOG_NOTICE,"Error sending file.");
break;
}
Expand All @@ -390,7 +389,7 @@ int Return_Resource(int conn, FILE *resource, struct ReqInfo * reqinfo) {
else{
while (!feof(resource)){
c = fgetc(resource);
if ( write(conn, &c, 1) < 1 ){
if ( send(conn, &c, 1,MSG_NOSIGNAL) < 1 ){
syslog(LOG_NOTICE,"Error sending file.");
break;
}
Expand Down

0 comments on commit ab13f2c

Please sign in to comment.