Browse Source

Initial support of SunCC compiler provided

master
Artyom Beilis 14 years ago
parent
commit
0472fe55d8
14 changed files with 78 additions and 40 deletions
  1. +2
    -2
      CMakeLists.txt
  2. +1
    -1
      application.h
  3. +1
    -0
      cgi_api.cpp
  4. +1
    -1
      config.js
  5. +2
    -3
      connection_forwarder.cpp
  6. +2
    -0
      fastcgi_api.cpp
  7. +16
    -6
      http_api.cpp
  8. +5
    -4
      http_context.cpp
  9. +1
    -0
      http_request.cpp
  10. +30
    -9
      posix_util.h
  11. +1
    -0
      scgi_api.cpp
  12. +11
    -12
      service.cpp
  13. +4
    -1
      session_posix_file_storage.cpp
  14. +1
    -1
      session_sid.cpp

+ 2
- 2
CMakeLists.txt View File

@@ -194,7 +194,7 @@ set(CPPCMS_PUBLIC_HEADERS
callback3.h
callback4.h
clone_ptr.h
connection_forwarder.h
# connection_forwarder.h
copy_ptr.h
cppcms_error.h
cstdint.h
@@ -292,7 +292,7 @@ set(CPPCMS_SOURCES
cache_pool.cpp
cache_interface.cpp
thread_cache.cpp
connection_forwarder.cpp
# connection_forwarder.cpp
session_pool.cpp
base_encryptor.cpp
hmac_encryptor.cpp


+ 1
- 1
application.h View File

@@ -6,7 +6,7 @@
#include "atomic_counter.h"
#include "hold_ptr.h"
#include "intrusive_ptr.h"
#include <string>

namespace cppcms {



+ 1
- 0
cgi_api.cpp View File

@@ -11,6 +11,7 @@
#include "cgi_api.h"
#include "util.h"

#include <stdlib.h>
#include "config.h"
#ifdef CPPCMS_USE_EXTERNAL_BOOST
# include <boost/bind.hpp>


+ 1
- 1
config.js View File

@@ -80,7 +80,7 @@
"views" : {
"default_skin" : "skin1",
"paths" : [ "./" ],
"skins" : [ "skin3" ],
//"skins" : [ "skin3" ],
"auto_reload" : true
},
"cache" : {


+ 2
- 3
connection_forwarder.cpp View File

@@ -42,12 +42,11 @@ namespace cppcms {
{
data_.swap(data);
boost::asio::ip::tcp::endpoint ep(boost::asio::ip::address::from_string(ip_),port_);
boost::system::error_code err;
socket_.async_connect(ep,boost::bind(&tcp_pipe::on_connected,shared_from_this(),_1));
socket_.async_connect(ep,boost::bind(&tcp_pipe::on_connected,shared_from_this(),boost::asio::placeholders::error));
}
private:

void on_connected(boost::system::error_code const &e)
void on_connected(boost::system::error_code e)
{
if(e) {
connection_->response().make_error_response(500);


+ 2
- 0
fastcgi_api.cpp View File

@@ -7,6 +7,8 @@
#include "cppcms_error_category.h"
#include "json.h"
#include "cstdint.h"
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include "config.h"
#ifdef CPPCMS_USE_EXTERNAL_BOOST


+ 16
- 6
http_api.cpp View File

@@ -8,6 +8,7 @@
#include "json.h"
#include "http_protocol.h"
#include "config.h"
#include <string.h>
#include <iostream>
#include <algorithm>
#ifdef CPPCMS_USE_EXTERNAL_BOOST
@@ -49,17 +50,26 @@ namespace cgi {
boost::system::error_code e;
socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both,e);
}
struct binder {
void operator()(boost::system::error_code const &e,size_t n) const
{
self_->some_headers_data_read(e,n,h_);
}
binder(intrusive_ptr<http> self,handler const &h) :
self_(self),
h_(h)
{
}
private:
intrusive_ptr<http> self_;
handler h_;
};
virtual void async_read_headers(handler const &h)
{
input_body_.reserve(8192);
input_body_.resize(8192,0);
input_body_ptr_=0;
socket_.async_read_some(boost::asio::buffer(input_body_),
boost::bind( &http::some_headers_data_read,
self(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred,
h));
socket_.async_read_some(boost::asio::buffer(input_body_),binder(self(),h));
}

void some_headers_data_read(boost::system::error_code const &e,size_t n,handler const &h)


+ 5
- 4
http_context.cpp View File

@@ -96,8 +96,7 @@ void context::on_request_ready(bool error)
app->service().thread_pool().post(boost::bind(&context::dispatch,app,matched,true));
}
}

/* static */
// static
void context::dispatch(intrusive_ptr<application> app,std::string url,bool syncronous)
{
try {
@@ -170,7 +169,8 @@ context::~context()

void context::async_on_peer_reset(util::callback0 const &h)
{
conn_->aync_wait_for_close_by_peer(h);
// For some wired can't go without bind on SunCC
conn_->aync_wait_for_close_by_peer(boost::bind(h));
}

impl::cgi::connection &context::connection()
@@ -217,6 +217,7 @@ session_interface &context::session()
return *d->session;
}


} // http
} // cppcms



+ 1
- 0
http_request.cpp View File

@@ -7,6 +7,7 @@
#include "util.h"

#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#ifdef CPPCMS_USE_EXTERNAL_BOOST
# include <boost/shared_ptr.hpp>


+ 30
- 9
posix_util.h View File

@@ -4,9 +4,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include "cppcms_error.h"

@@ -106,7 +107,7 @@ namespace impl {
catch(cppcms_error const &e) {
res= false;
}
::munmap(memory,sizeof(pthread_mutex_t));
::munmap((char*)memory,sizeof(pthread_mutex_t));
return res;
}

@@ -147,7 +148,11 @@ namespace impl {
{
pthread_mutex_lock(plock_);
if(flock_) {
while(::flock(fileno(flock_),LOCK_EX)<0 && errno==EINTR)
struct flock lock;
memset(&lock,0,sizeof(lock));
lock.l_type=F_WRLCK;
lock.l_whence=SEEK_SET;
while(::fcntl(fileno(flock_),F_SETLKW,&lock)!=0 && errno==EINTR)
;
}
}
@@ -155,7 +160,11 @@ namespace impl {
void unlock()
{
if(flock_) {
while(::flock(fileno(flock_),LOCK_UN)<0 && errno==EINTR)
struct flock lock;
memset(&lock,0,sizeof(lock));
lock.l_type=F_UNLCK;
lock.l_whence=SEEK_SET;
while(::fcntl(fileno(flock_),F_SETLKW,&lock)!=0 && errno==EINTR)
;
}
pthread_mutex_unlock(plock_);
@@ -166,7 +175,7 @@ namespace impl {
if(flock_) ::fclose(flock_);
destroy_mutex(plock_);
if(plock_ != &normal_)
::munmap(plock_,sizeof(pthread_mutex_t));
::munmap((char*)plock_,sizeof(pthread_mutex_t));
}
private:
pthread_mutex_t *plock_;
@@ -219,7 +228,11 @@ namespace impl {
{
pthread_rwlock_wrlock(plock_);
if(flock_) {
while(::flock(fileno(flock_),LOCK_EX)<0 && errno==EINTR)
struct flock lock;
memset(&lock,0,sizeof(lock));
lock.l_type=F_WRLCK;
lock.l_whence=SEEK_SET;
while(::fcntl(fileno(flock_),F_SETLKW,&lock)!=0 && errno==EINTR)
;
}
}
@@ -228,7 +241,11 @@ namespace impl {
{
pthread_rwlock_rdlock(plock_);
if(flock_) {
while(::flock(fileno(flock_),LOCK_SH)<0 && errno==EINTR)
struct flock lock;
memset(&lock,0,sizeof(lock));
lock.l_type=F_RDLCK;
lock.l_whence=SEEK_SET;
while(::fcntl(fileno(flock_),F_SETLKW,&lock)!=0 && errno==EINTR)
;
}
}
@@ -236,7 +253,11 @@ namespace impl {
void unlock()
{
if(flock_) {
while(::flock(fileno(flock_),LOCK_UN)<0 && errno==EINTR)
struct flock lock;
memset(&lock,0,sizeof(lock));
lock.l_type=F_UNLCK;
lock.l_whence=SEEK_SET;
while(::fcntl(fileno(flock_),F_SETLKW,&lock)!=0 && errno==EINTR)
;
}
pthread_rwlock_unlock(plock_);
@@ -247,7 +268,7 @@ namespace impl {
if(flock_) ::fclose(flock_);
destroy_rwlock(plock_);
if(plock_ != &normal_)
::munmap(plock_,sizeof(pthread_rwlock_t));
::munmap((char*)plock_,sizeof(pthread_rwlock_t));
}
private:
pthread_rwlock_t *plock_;


+ 1
- 0
scgi_api.cpp View File

@@ -7,6 +7,7 @@
#include "service_impl.h"
#include "cppcms_error_category.h"
#include <iostream>
#include <stdlib.h>
#include "config.h"
#ifdef CPPCMS_USE_EXTERNAL_BOOST
# include <boost/bind.hpp>


+ 11
- 12
service.cpp View File

@@ -1,4 +1,10 @@
#define CPPCMS_SOURCE
#ifndef CPPCMS_WIN32
#if defined(__sun)
#define _POSIX_PTHREAD_SEMANTICS
#endif
#include <signal.h>
#endif
#include "asio_config.h"
#include "service.h"
#include "service_impl.h"
@@ -22,13 +28,6 @@
#include <sys/wait.h>
#endif

#ifndef CPPCMS_WIN32
#if defined(SOLARIS) || defined(_SOLARIS)
#define _POSIX_PTHREAD_SEMANTICS
#endif
#include <signal.h>
#endif

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -388,12 +387,12 @@ bool service::prefork()
// Ingnore all processes that are not my own childrens
if(p!=pids.end()) {
// TODO: Make better error handling
if(!WIFEXITED(stat) || WEXITSTATUS(stat)!=0){
if(WIFEXITED(stat)) {
std::cerr<<"Chaild exited with "<<WEXITSTATUS(stat)<<std::endl;
if(!WIFEXITED(status) || WEXITSTATUS(status)!=0){
if(WIFEXITED(status)) {
std::cerr<<"Chaild exited with "<<WEXITSTATUS(status)<<std::endl;
}
else if(WIFSIGNALED(stat)) {
std::cerr<<"Chaild killed by "<<WTERMSIG(stat)<<std::endl;
else if(WIFSIGNALED(status)) {
std::cerr<<"Chaild killed by "<<WTERMSIG(status)<<std::endl;
}
else {
std::cerr<<"Chaild exited for unknown reason"<<std::endl;


+ 4
- 1
session_posix_file_storage.cpp View File

@@ -1,4 +1,7 @@
#define CPPCMS_SOURCE
#if defined(__sun)
#define _POSIX_PTHREAD_SEMANTICS
#endif
#include "session_posix_file_storage.h"
#include "cppcms_error.h"
#include "config.h"
@@ -83,7 +86,7 @@ session_file_storage::~session_file_storage()
if(memory_ !=MAP_FAILED) {
for(unsigned i=0;i<lock_size_;i++)
destroy_mutex(reinterpret_cast<pthread_mutex_t *>(memory_) + i);
munmap(memory_,sizeof(pthread_mutex_t) * lock_size_);
munmap((char*)memory_,sizeof(pthread_mutex_t) * lock_size_);
}
else {
for(unsigned i=0;i<lock_size_;i++)


+ 1
- 1
session_sid.cpp View File

@@ -6,7 +6,7 @@
#include <fstream>
#include "cppcms_error.h"
#include "urandom.h"
#include <stdio.h>
#include <time.h>

#ifndef CPPCMS_WIN_NATIVE


Loading…
Cancel
Save