[trunk] continue work on getting API to use off_t instead of long toward LFS support in JPIP (sock_manager)
This commit is contained in:
parent
ccdfaa9115
commit
cdf0d77b20
|
@ -51,7 +51,7 @@
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif /*SERVER*/
|
#endif /*SERVER*/
|
||||||
|
|
||||||
SOCKET open_listeningsocket( int port)
|
SOCKET open_listeningsocket( uint16_t port)
|
||||||
{
|
{
|
||||||
SOCKET listening_socket;
|
SOCKET listening_socket;
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
|
@ -100,36 +100,36 @@ SOCKET accept_socket( SOCKET listening_socket)
|
||||||
void send_stream( SOCKET connected_socket, void *stream, OPJ_SIZE_T length)
|
void send_stream( SOCKET connected_socket, void *stream, OPJ_SIZE_T length)
|
||||||
{
|
{
|
||||||
char *ptr = (char*)stream;
|
char *ptr = (char*)stream;
|
||||||
int remlen = length;
|
OPJ_SIZE_T remlen = length;
|
||||||
|
|
||||||
while( remlen > 0){
|
while( remlen > 0){
|
||||||
int sentlen = send( connected_socket, ptr, remlen, 0);
|
ssize_t sentlen = send( connected_socket, ptr, remlen, 0);
|
||||||
if( sentlen == -1){
|
if( sentlen == -1){
|
||||||
fprintf( FCGI_stderr, "sending stream error\n");
|
fprintf( FCGI_stderr, "sending stream error\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
remlen = remlen - sentlen;
|
remlen = remlen - (OPJ_SIZE_T)sentlen;
|
||||||
ptr = ptr + sentlen;
|
ptr = ptr + sentlen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void * receive_stream( SOCKET connected_socket, int length)
|
void * receive_stream( SOCKET connected_socket, OPJ_SIZE_T length)
|
||||||
{
|
{
|
||||||
char *stream, *ptr;
|
char *stream, *ptr;
|
||||||
int remlen, redlen;
|
OPJ_SIZE_T remlen;
|
||||||
|
|
||||||
ptr = stream = malloc( length);
|
ptr = stream = malloc( length);
|
||||||
remlen = length;
|
remlen = length;
|
||||||
|
|
||||||
while( remlen > 0){
|
while( remlen > 0){
|
||||||
redlen = recv( connected_socket, ptr, remlen, 0);
|
ssize_t redlen = recv( connected_socket, ptr, remlen, 0);
|
||||||
if( redlen == -1){
|
if( redlen == -1){
|
||||||
fprintf( FCGI_stderr, "receive stream error\n");
|
fprintf( FCGI_stderr, "receive stream error\n");
|
||||||
free( stream);
|
free( stream);
|
||||||
stream = NULL;
|
stream = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
remlen -= redlen;
|
remlen -= (OPJ_SIZE_T)redlen;
|
||||||
ptr = ptr + redlen;
|
ptr = ptr + redlen;
|
||||||
}
|
}
|
||||||
return stream;
|
return stream;
|
||||||
|
@ -139,7 +139,7 @@ int receive_line(SOCKET connected_socket, char *p)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
while (1){
|
while (1){
|
||||||
int ret;
|
ssize_t ret;
|
||||||
ret = recv( connected_socket, p, 1, 0);
|
ret = recv( connected_socket, p, 1, 0);
|
||||||
if ( ret == -1 ){
|
if ( ret == -1 ){
|
||||||
perror("receive");
|
perror("receive");
|
||||||
|
@ -164,6 +164,8 @@ char * receive_string( SOCKET connected_socket)
|
||||||
{
|
{
|
||||||
char buf[BUF_LEN];
|
char buf[BUF_LEN];
|
||||||
|
|
||||||
|
/* MM FIXME: there is a nasty bug here, size of buf if BUF_LEN which is never
|
||||||
|
indicated to downstream receive_line */
|
||||||
receive_line( connected_socket, buf);
|
receive_line( connected_socket, buf);
|
||||||
|
|
||||||
return strdup(buf);
|
return strdup(buf);
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include "bool.h"
|
#include "bool.h"
|
||||||
#include "byte_manager.h"
|
#include "byte_manager.h"
|
||||||
|
#include "opj_stdint.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
|
@ -48,7 +49,7 @@ typedef int SOCKET;
|
||||||
* @param port opening port number
|
* @param port opening port number
|
||||||
* @return new socket
|
* @return new socket
|
||||||
*/
|
*/
|
||||||
SOCKET open_listeningsocket( int port);
|
SOCKET open_listeningsocket( uint16_t port);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* accept a new connection to the listenning socket
|
* accept a new connection to the listenning socket
|
||||||
|
@ -83,7 +84,7 @@ char * receive_string( SOCKET connected_socket);
|
||||||
* @param [in] length length of the receiving stream
|
* @param [in] length length of the receiving stream
|
||||||
* @return pointer to the data stream (memory allocated), NULL if failed
|
* @return pointer to the data stream (memory allocated), NULL if failed
|
||||||
*/
|
*/
|
||||||
void * receive_stream( SOCKET connected_socket, int length);
|
void * receive_stream( SOCKET connected_socket, OPJ_SIZE_T length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* send data stream to client
|
* send data stream to client
|
||||||
|
|
Loading…
Reference in New Issue