Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 596078
Collapse All | Expand All

(-)pficommon-1.3.1.0.old/src/concurrent/pcbuf_test.cpp (-2 / +2 lines)
Lines 151-157 Link Here
151
  // start consumers
151
  // start consumers
152
  vector<shared_ptr<thread> > consumers(consumer_num);
152
  vector<shared_ptr<thread> > consumers(consumer_num);
153
  for (size_t i = 0; i < consumers.size(); i++) {
153
  for (size_t i = 0; i < consumers.size(); i++) {
154
    function<void(void)> f = bind(consumer_func,
154
    pfi::lang::function<void(void)> f = bind(consumer_func,
155
                                  &q,
155
                                  &q,
156
                                  &shutdown_flag,
156
                                  &shutdown_flag,
157
                                  &consumer_histgram,
157
                                  &consumer_histgram,
Lines 163-169 Link Here
163
  // start producers
163
  // start producers
164
  vector<shared_ptr<thread> > producers(producer_num);
164
  vector<shared_ptr<thread> > producers(producer_num);
165
  for (size_t i = 0; i < producers.size(); i++) {
165
  for (size_t i = 0; i < producers.size(); i++) {
166
    function<void(void)> f = bind(producer_func,
166
    pfi::lang::function<void(void)> f = bind(producer_func,
167
                                  &q,
167
                                  &q,
168
                                  produced_data_min,
168
                                  produced_data_min,
169
                                  produced_data_max,
169
                                  produced_data_max,
(-)pficommon-1.3.1.0.old/src/concurrent/thread.cpp (-6 / +6 lines)
Lines 44-50 Link Here
44
44
45
class thread::impl : noncopyable{
45
class thread::impl : noncopyable{
46
public:
46
public:
47
  impl(const function<void()> &f);
47
  impl(const pfi::lang::function<void()> &f);
48
  ~impl();
48
  ~impl();
49
49
50
  bool start();
50
  bool start();
Lines 57-66 Link Here
57
  bool running;
57
  bool running;
58
  pthread_t tid;
58
  pthread_t tid;
59
59
60
  function<void()> f;
60
  pfi::lang::function<void()> f;
61
};
61
};
62
62
63
thread::thread(const function<void()> &f)
63
thread::thread(const pfi::lang::function<void()> &f)
64
  :pimpl(new impl(f))
64
  :pimpl(new impl(f))
65
{
65
{
66
}
66
}
Lines 115-121 Link Here
115
#endif
115
#endif
116
}
116
}
117
117
118
thread::impl::impl(const function<void()> &f)
118
thread::impl::impl(const pfi::lang::function<void()> &f)
119
  : running(false)
119
  : running(false)
120
  , tid(0)
120
  , tid(0)
121
  , f(f)
121
  , f(f)
Lines 134-140 Link Here
134
  if (running) return false;
134
  if (running) return false;
135
135
136
  running=true;
136
  running=true;
137
  function<void()> *pf=new function<void()>(f);
137
  pfi::lang::function<void()> *pf=new pfi::lang::function<void()>(f);
138
  int res=pthread_create(&tid,NULL,start_routine,(void*)pf);
138
  int res=pthread_create(&tid,NULL,start_routine,(void*)pf);
139
  if (res!=0){
139
  if (res!=0){
140
    delete pf;
140
    delete pf;
Lines 177-183 Link Here
177
177
178
void *thread::impl::start_routine(void *p)
178
void *thread::impl::start_routine(void *p)
179
{
179
{
180
  function<void()> *pf=reinterpret_cast<function<void()>*>(p);
180
  pfi::lang::function<void()> *pf=reinterpret_cast<pfi::lang::function<void()>*>(p);
181
  (*pf)();
181
  (*pf)();
182
  delete pf;
182
  delete pf;
183
  return NULL;
183
  return NULL;
(-)pficommon-1.3.1.0.old/src/data/serialization_test.cpp (-4 / +4 lines)
Lines 297-321 Link Here
297
297
298
TEST(serialization, reflect) {
298
TEST(serialization, reflect) {
299
  {
299
  {
300
    shared_ptr<type_rep> t=get_type<vector<uint16_t> >();
300
    pfi::lang::shared_ptr<type_rep> t=get_type<vector<uint16_t> >();
301
    ostringstream oss;
301
    ostringstream oss;
302
    t->print(oss);
302
    t->print(oss);
303
    EXPECT_EQ(oss.str(), "array<uint(2)>");
303
    EXPECT_EQ(oss.str(), "array<uint(2)>");
304
  }
304
  }
305
  {
305
  {
306
    shared_ptr<type_rep> t=get_type<vector<int32_t> >();
306
    pfi::lang::shared_ptr<type_rep> t=get_type<vector<int32_t> >();
307
    ostringstream oss;
307
    ostringstream oss;
308
    t->print(oss);
308
    t->print(oss);
309
    EXPECT_EQ(oss.str(), "array<int(4)>");
309
    EXPECT_EQ(oss.str(), "array<int(4)>");
310
  }
310
  }
311
  {
311
  {
312
    shared_ptr<type_rep> t=get_type<map<int, string> >();
312
    pfi::lang::shared_ptr<type_rep> t=get_type<map<int, string> >();
313
    ostringstream oss;
313
    ostringstream oss;
314
    t->print(oss);
314
    t->print(oss);
315
    EXPECT_EQ(oss.str(), "map<int(4),string>");
315
    EXPECT_EQ(oss.str(), "map<int(4),string>");
316
  }
316
  }
317
  {
317
  {
318
    shared_ptr<type_rep> t=get_type<vector<map<vector<int>, string> > >();
318
    pfi::lang::shared_ptr<type_rep> t=get_type<vector<map<vector<int>, string> > >();
319
    ostringstream oss;
319
    ostringstream oss;
320
    t->print(oss);
320
    t->print(oss);
321
    EXPECT_EQ(oss.str(), "array<map<array<int(4)>,string>>");
321
    EXPECT_EQ(oss.str(), "array<map<array<int(4)>,string>>");
(-)pficommon-1.3.1.0.old/src/database/mysql/connection.cpp (-3 / +3 lines)
Lines 145-164 Link Here
145
}
145
}
146
146
147
int mysql_connection::run(const string &sql,
147
int mysql_connection::run(const string &sql,
148
			  const vector<shared_ptr<sql_value> > &args)
148
			  const vector<pfi::lang::shared_ptr<sql_value> > &args)
149
{
149
{
150
  if (conn->get() == NULL) reconnect();
150
  if (conn->get() == NULL) reconnect();
151
151
152
  // TODO: optimize
152
  // TODO: optimize
153
  try {
153
  try {
154
    shared_ptr<statement> stat(prepare(sql));
154
    pfi::lang::shared_ptr<statement> stat(prepare(sql));
155
    return stat->execute(args);
155
    return stat->execute(args);
156
  }
156
  }
157
  catch (const connection_error &e) {
157
  catch (const connection_error &e) {
158
    reconnect(); // this function rethrows an exception if necessary
158
    reconnect(); // this function rethrows an exception if necessary
159
  }
159
  }
160
160
161
  shared_ptr<statement> stat(prepare(sql));
161
  pfi::lang::shared_ptr<statement> stat(prepare(sql));
162
  return stat->execute(args);
162
  return stat->execute(args);
163
}
163
}
164
164
(-)pficommon-1.3.1.0.old/src/database/mysql/statement.cpp (-3 / +3 lines)
Lines 48-54 Link Here
48
namespace database{
48
namespace database{
49
namespace mysql{
49
namespace mysql{
50
50
51
mysql_statement::mysql_statement(shared_ptr<mysql_connection_impl,
51
mysql_statement::mysql_statement(pfi::lang::shared_ptr<mysql_connection_impl,
52
                                   pfi::concurrent::threading_model::multi_thread> &conn,
52
                                   pfi::concurrent::threading_model::multi_thread> &conn,
53
				 const string &query)
53
				 const string &query)
54
  :conn(conn),meta(NULL)
54
  :conn(conn),meta(NULL)
Lines 98-104 Link Here
98
  mysql_stmt_close(stmt);
98
  mysql_stmt_close(stmt);
99
}
99
}
100
100
101
int mysql_statement::execute(const vector<shared_ptr<sql_value> > &args)
101
int mysql_statement::execute(const vector<pfi::lang::shared_ptr<sql_value> > &args)
102
{
102
{
103
  if (param_count!=args.size()){
103
  if (param_count!=args.size()){
104
    ostringstream msg;
104
    ostringstream msg;
Lines 146-152 Link Here
146
  return 0;
146
  return 0;
147
}
147
}
148
148
149
bool mysql_statement::fetch_row(vector<shared_ptr<sql_value> > &row)
149
bool mysql_statement::fetch_row(vector<pfi::lang::shared_ptr<sql_value> > &row)
150
{
150
{
151
  static const size_t INIT_BUF_SIZE = 16*1024;
151
  static const size_t INIT_BUF_SIZE = 16*1024;
152
  
152
  
(-)pficommon-1.3.1.0.old/src/database/mysql/value.cpp (-5 / +5 lines)
Lines 88-101 Link Here
88
  }
88
  }
89
}
89
}
90
90
91
shared_ptr<sql_value> from_bind(MYSQL_BIND &bind)
91
pfi::lang::shared_ptr<sql_value> from_bind(MYSQL_BIND &bind)
92
{
92
{
93
  sql_value *p=from_bind_p(bind);
93
  sql_value *p=from_bind_p(bind);
94
  if (!p) return shared_ptr<sql_value>();
94
  if (!p) return pfi::lang::shared_ptr<sql_value>();
95
  return shared_ptr<sql_value>(p);
95
  return pfi::lang::shared_ptr<sql_value>(p);
96
}
96
}
97
97
98
size_t bind_length(shared_ptr<sql_value> p)
98
size_t bind_length(pfi::lang::shared_ptr<sql_value> p)
99
{
99
{
100
  if (!p) return 0;
100
  if (!p) return 0;
101
101
Lines 119-125 Link Here
119
  }
119
  }
120
}
120
}
121
121
122
void to_bind(shared_ptr<sql_value> p, MYSQL_BIND &bind)
122
void to_bind(pfi::lang::shared_ptr<sql_value> p, MYSQL_BIND &bind)
123
{
123
{
124
  if (!p){
124
  if (!p){
125
    bind.is_null=NULL;
125
    bind.is_null=NULL;
(-)pficommon-1.3.1.0.old/src/database/postgresql/connection.cpp (-2 / +2 lines)
Lines 108-116 Link Here
108
  (void)connection::run("ROLLBACK");
108
  (void)connection::run("ROLLBACK");
109
}
109
}
110
110
111
int postgresql_connection::run(const string &sql, const vector<shared_ptr<sql_value> > &args)
111
int postgresql_connection::run(const string &sql, const vector<pfi::lang::shared_ptr<sql_value> > &args)
112
{
112
{
113
  shared_ptr<statement> stat(prepare(sql));
113
  pfi::lang::shared_ptr<statement> stat(prepare(sql));
114
  return stat->execute(args);
114
  return stat->execute(args);
115
}
115
}
116
116
(-)pficommon-1.3.1.0.old/src/database/postgresql/statement.cpp (-6 / +6 lines)
Lines 58-64 Link Here
58
  return oss.str();
58
  return oss.str();
59
}
59
}
60
60
61
postgresql_statement::postgresql_statement(shared_ptr<postgresql_connection_impl> conn,
61
postgresql_statement::postgresql_statement(pfi::lang::shared_ptr<postgresql_connection_impl> conn,
62
					   const string &query)
62
					   const string &query)
63
  : conn(conn)
63
  : conn(conn)
64
{
64
{
Lines 72-81 Link Here
72
{
72
{
73
}
73
}
74
74
75
int postgresql_statement::execute(const vector<shared_ptr<sql_value> > &args)
75
int postgresql_statement::execute(const vector<pfi::lang::shared_ptr<sql_value> > &args)
76
{
76
{
77
  int n=args.size();
77
  int n=args.size();
78
  vector<shared_ptr<string> > sparams(n);
78
  vector<pfi::lang::shared_ptr<string> > sparams(n);
79
  vector<const char *> params(n);
79
  vector<const char *> params(n);
80
  vector<int> param_lens(n);
80
  vector<int> param_lens(n);
81
81
Lines 95-102 Link Here
95
  if (r==NULL)
95
  if (r==NULL)
96
    throw database_error("PQexecPrepared failed");
96
    throw database_error("PQexecPrepared failed");
97
97
98
  shared_ptr<postgresql_result> rtmp=
98
  pfi::lang::shared_ptr<postgresql_result> rtmp=
99
    shared_ptr<postgresql_result>(new postgresql_result(r));
99
    pfi::lang::shared_ptr<postgresql_result>(new postgresql_result(r));
100
100
101
  if (!rtmp->command_ok() &&
101
  if (!rtmp->command_ok() &&
102
      !rtmp->tuple_ok())
102
      !rtmp->tuple_ok())
Lines 108-114 Link Here
108
  return 0;
108
  return 0;
109
}
109
}
110
110
111
bool postgresql_statement::fetch_row(vector<shared_ptr<sql_value> > &row)
111
bool postgresql_statement::fetch_row(vector<pfi::lang::shared_ptr<sql_value> > &row)
112
{
112
{
113
  if (!res) return false;
113
  if (!res) return false;
114
  return res->fetch_row(row);
114
  return res->fetch_row(row);
(-)pficommon-1.3.1.0.old/src/database/postgresql/value.cpp (-12 / +12 lines)
Lines 115-150 Link Here
115
  }
115
  }
116
}
116
}
117
117
118
shared_ptr<sql_value> str_to_sql(char *p, int len, int is_null, Oid oid)
118
pfi::lang::shared_ptr<sql_value> str_to_sql(char *p, int len, int is_null, Oid oid)
119
{
119
{
120
  if (is_null) return shared_ptr<sql_value>();
120
  if (is_null) return pfi::lang::shared_ptr<sql_value>();
121
  sql_type t=oid_to_sql_type(oid);
121
  sql_type t=oid_to_sql_type(oid);
122
  return shared_ptr<sql_value>(make_sql_value(p, len, t));
122
  return pfi::lang::shared_ptr<sql_value>(make_sql_value(p, len, t));
123
}
123
}
124
124
125
shared_ptr<string> sql_to_str(shared_ptr<sql_value> p)
125
pfi::lang::shared_ptr<string> sql_to_str(pfi::lang::shared_ptr<sql_value> p)
126
{
126
{
127
  if (!p) return shared_ptr<string>();
127
  if (!p) return pfi::lang::shared_ptr<string>();
128
128
129
  switch(p->type()){
129
  switch(p->type()){
130
  case SQL_BOOL:{
130
  case SQL_BOOL:{
131
    static const string t("true");
131
    static const string t("true");
132
    static const string f("false");
132
    static const string f("false");
133
    return shared_ptr<string>(new string(dynamic_cast<sql_bool*>(p.get())->get()?t:f));
133
    return pfi::lang::shared_ptr<string>(new string(dynamic_cast<sql_bool*>(p.get())->get()?t:f));
134
  }
134
  }
135
  case SQL_STRING:{
135
  case SQL_STRING:{
136
    return shared_ptr<string>(new string(dynamic_cast<sql_string*>(p.get())->get()));
136
    return pfi::lang::shared_ptr<string>(new string(dynamic_cast<sql_string*>(p.get())->get()));
137
  }
137
  }
138
  case SQL_INT32:{
138
  case SQL_INT32:{
139
    return shared_ptr<string>(new string(lexical_cast<string>(dynamic_cast<sql_int32*>(p.get())->get())));
139
    return pfi::lang::shared_ptr<string>(new string(lexical_cast<string>(dynamic_cast<sql_int32*>(p.get())->get())));
140
  }
140
  }
141
  case SQL_INT64:{
141
  case SQL_INT64:{
142
    return shared_ptr<string>(new string(lexical_cast<string>(dynamic_cast<sql_int64*>(p.get())->get())));
142
    return pfi::lang::shared_ptr<string>(new string(lexical_cast<string>(dynamic_cast<sql_int64*>(p.get())->get())));
143
  }
143
  }
144
  case SQL_FLOAT:{
144
  case SQL_FLOAT:{
145
    ostringstream oss;
145
    ostringstream oss;
146
    oss<<setiosflags(ios::fixed)<<setprecision(10)<<dynamic_cast<sql_float*>(p.get())->get();
146
    oss<<setiosflags(ios::fixed)<<setprecision(10)<<dynamic_cast<sql_float*>(p.get())->get();
147
    return shared_ptr<string>(new string(oss.str()));
147
    return pfi::lang::shared_ptr<string>(new string(oss.str()));
148
  }
148
  }
149
  case SQL_TIMESTAMP:{
149
  case SQL_TIMESTAMP:{
150
    calendar_time ct(dynamic_cast<sql_timestamp*>(p.get())->get());
150
    calendar_time ct(dynamic_cast<sql_timestamp*>(p.get())->get());
Lines 159-168 Link Here
159
    strftime(buf, sizeof(buf), "%Y-%m-%d %T.", &t);
159
    strftime(buf, sizeof(buf), "%Y-%m-%d %T.", &t);
160
    sprintf(ubuf, "%06d", ct.usec);
160
    sprintf(ubuf, "%06d", ct.usec);
161
    strcat(buf, ubuf);
161
    strcat(buf, ubuf);
162
    return shared_ptr<string>(new string(buf));
162
    return pfi::lang::shared_ptr<string>(new string(buf));
163
  }
163
  }
164
  case SQL_UNKNOWN:{
164
  case SQL_UNKNOWN:{
165
    return shared_ptr<string>(new string(dynamic_cast<sql_unknown*>(p.get())->get()));
165
    return pfi::lang::shared_ptr<string>(new string(dynamic_cast<sql_unknown*>(p.get())->get()));
166
  }
166
  }
167
  default:
167
  default:
168
    abort();
168
    abort();
(-)pficommon-1.3.1.0.old/src/math/random_test.cpp (-4 / +4 lines)
Lines 52-58 Link Here
52
52
53
53
54
template <class t>
54
template <class t>
55
vector<t> moment(int max_mom, int size, function<t()> &val){
55
vector<t> moment(int max_mom, int size, pfi::lang::function<t()> &val){
56
  vector<t> mom(max_mom,0);
56
  vector<t> mom(max_mom,0);
57
  for(int i=0;i<size; ++i){
57
  for(int i=0;i<size; ++i){
58
    t x=val(); // test
58
    t x=val(); // test
Lines 100-108 Link Here
100
100
101
TEST(random, time_seed){
101
TEST(random, time_seed){
102
  typedef pfi::math::random::random<mersenne_twister> mt;
102
  typedef pfi::math::random::random<mersenne_twister> mt;
103
  shared_ptr<mt> r1(new mt);
103
  pfi::lang::shared_ptr<mt> r1(new mt);
104
  usleep(5);
104
  usleep(5);
105
  shared_ptr<mt> r2(new mt);
105
  pfi::lang::shared_ptr<mt> r2(new mt);
106
  for(int i=0;i<10;++i){
106
  for(int i=0;i<10;++i){
107
    int x=r1->next_int(), y=r2->next_int();
107
    int x=r1->next_int(), y=r2->next_int();
108
    EXPECT_TRUE(x!=y) << "x=" << x << " " << "y=" << y << endl;
108
    EXPECT_TRUE(x!=y) << "x=" << x << " " << "y=" << y << endl;
Lines 110-116 Link Here
110
  
110
  
111
}
111
}
112
112
113
bool is_standard_deviation(function<double()> f, bool expectation=true){
113
bool is_standard_deviation(pfi::lang::function<double()> f, bool expectation=true){
114
  // if f is standard deviation, it passes approx 99.99% probability.
114
  // if f is standard deviation, it passes approx 99.99% probability.
115
115
116
  int size=1<<22;
116
  int size=1<<22;
(-)pficommon-1.3.1.0.old/src/network/cgi/inserter.cpp (-4 / +4 lines)
Lines 50-57 Link Here
50
50
51
tag_inserter::~tag_inserter()
51
tag_inserter::~tag_inserter()
52
{
52
{
53
  shared_ptr<tag_elem> elem(new tag_elem(name, attrs));
53
  pfi::lang::shared_ptr<tag_elem> elem(new tag_elem(name, attrs));
54
  vector<shared_ptr<html_elem> > children=b.leave();
54
  vector<pfi::lang::shared_ptr<html_elem> > children=b.leave();
55
  for (int i=0;i<(int)children.size();i++)
55
  for (int i=0;i<(int)children.size();i++)
56
    elem->add_child(children[i]);
56
    elem->add_child(children[i]);
57
  b.push(elem);
57
  b.push(elem);
Lines 59-70 Link Here
59
59
60
text_inserter::text_inserter(const string &text, xhtml_builder &b)
60
text_inserter::text_inserter(const string &text, xhtml_builder &b)
61
{
61
{
62
  b.push(shared_ptr<html_elem>(new text_elem(text)));
62
  b.push(pfi::lang::shared_ptr<html_elem>(new text_elem(text)));
63
}
63
}
64
64
65
prim_inserter::prim_inserter(const string &text, xhtml_builder &b)
65
prim_inserter::prim_inserter(const string &text, xhtml_builder &b)
66
{
66
{
67
  b.push(shared_ptr<html_elem>(new prim_elem(text)));
67
  b.push(pfi::lang::shared_ptr<html_elem>(new prim_elem(text)));
68
}
68
}
69
69
70
} // cgi
70
} // cgi
(-)pficommon-1.3.1.0.old/src/network/cgi/server.cpp (-9 / +9 lines)
Lines 161-172 Link Here
161
      <<", thread-num="<<thread_num
161
      <<", thread-num="<<thread_num
162
      <<", timeout="<<ssock->timeout()<<endl;
162
      <<", timeout="<<ssock->timeout()<<endl;
163
163
164
  ths=vector<shared_ptr<thread> >(thread_num);
164
  ths=vector<pfi::lang::shared_ptr<thread> >(thread_num);
165
  vector<shared_ptr<cgi, threading_model::multi_thread> > cgis(thread_num);
165
  vector<pfi::lang::shared_ptr<cgi, threading_model::multi_thread> > cgis(thread_num);
166
166
167
  for (int i=0; i<thread_num; i++){
167
  for (int i=0; i<thread_num; i++){
168
    cgis[i]=shared_ptr<cgi, threading_model::multi_thread>(dynamic_cast<cgi*>(c.clone()));
168
    cgis[i]=pfi::lang::shared_ptr<cgi, threading_model::multi_thread>(dynamic_cast<cgi*>(c.clone()));
169
    ths[i]=shared_ptr<thread>(new thread(bind(&run_server::process, this, ssock, cgis[i])));
169
    ths[i]=pfi::lang::shared_ptr<thread>(new thread(bind(&run_server::process, this, ssock, cgis[i])));
170
    if (!ths[i]->start()){
170
    if (!ths[i]->start()){
171
      ostringstream oss;
171
      ostringstream oss;
172
      oss<<"unable to start thread"<<endl;
172
      oss<<"unable to start thread"<<endl;
Lines 185-191 Link Here
185
  ths.clear();
185
  ths.clear();
186
}
186
}
187
187
188
static shared_ptr<http::response> gen_resp(stringstream &ss)
188
static pfi::lang::shared_ptr<http::response> gen_resp(stringstream &ss)
189
{
189
{
190
  http::header head(ss);
190
  http::header head(ss);
191
191
Lines 210-216 Link Here
210
    head.erase("status");
210
    head.erase("status");
211
  }
211
  }
212
  
212
  
213
  shared_ptr<http::response> resp(new http::response(code, reason));
213
  pfi::lang::shared_ptr<http::response> resp(new http::response(code, reason));
214
214
215
  head["Content-Type"]=content_type;
215
  head["Content-Type"]=content_type;
216
216
Lines 232-241 Link Here
232
}
232
}
233
233
234
void run_server::process(socket_type ssock,
234
void run_server::process(socket_type ssock,
235
			 shared_ptr<cgi, threading_model::multi_thread> cc)
235
			 pfi::lang::shared_ptr<cgi, threading_model::multi_thread> cc)
236
{
236
{
237
  for (;;){
237
  for (;;){
238
    shared_ptr<stream_socket> sock(ssock->accept());
238
    pfi::lang::shared_ptr<stream_socket> sock(ssock->accept());
239
    if (!sock) continue;
239
    if (!sock) continue;
240
240
241
    if (ssock->timeout()>0 && !sock->set_timeout(ssock->timeout()))
241
    if (ssock->timeout()>0 && !sock->set_timeout(ssock->timeout()))
Lines 272-278 Link Here
272
272
273
      cc->exec(req.body(), sout, cerr, env);
273
      cc->exec(req.body(), sout, cerr, env);
274
274
275
      shared_ptr<http::response> resp=gen_resp(sout);
275
      pfi::lang::shared_ptr<http::response> resp=gen_resp(sout);
276
      resp->send(sock);
276
      resp->send(sock);
277
    }
277
    }
278
    catch(const exception &e){
278
    catch(const exception &e){
(-)pficommon-1.3.1.0.old/src/network/http/base.cpp (-21 / +21 lines)
Lines 61-67 Link Here
61
{
61
{
62
}
62
}
63
63
64
void header::read_header(function<bool(string*)> f)
64
void header::read_header(pfi::lang::function<bool(string*)> f)
65
{
65
{
66
  string line, key, val;
66
  string line, key, val;
67
  if (!f(&line))
67
  if (!f(&line))
Lines 124-130 Link Here
124
  return sock->getline(*str, line_limit);
124
  return sock->getline(*str, line_limit);
125
}
125
}
126
126
127
header::header(shared_ptr<stream_socket> sock)
127
header::header(pfi::lang::shared_ptr<stream_socket> sock)
128
{
128
{
129
  read_header(bind(&socket_getline, sock.get(), _1, line_limit));
129
  read_header(bind(&socket_getline, sock.get(), _1, line_limit));
130
}
130
}
Lines 211-217 Link Here
211
  return dat.end();
211
  return dat.end();
212
}
212
}
213
213
214
void header::send(shared_ptr<stream_socket> sock)
214
void header::send(pfi::lang::shared_ptr<stream_socket> sock)
215
{
215
{
216
  for (int i=0;i<(int)dat.size();i++){
216
  for (int i=0;i<(int)dat.size();i++){
217
    string line=dat[i].first+": "+dat[i].second+"\r\n";
217
    string line=dat[i].first+": "+dat[i].second+"\r\n";
Lines 228-234 Link Here
228
public:
228
public:
229
  typedef C char_type;
229
  typedef C char_type;
230
230
231
  basic_httpbody_chunked_streambuf(shared_ptr<stream_socket> sock)
231
  basic_httpbody_chunked_streambuf(pfi::lang::shared_ptr<stream_socket> sock)
232
    : sock(sock)
232
    : sock(sock)
233
    , chunk_rest(0)
233
    , chunk_rest(0)
234
    , buf(buf_size)
234
    , buf(buf_size)
Lines 321-327 Link Here
321
    iss>>hex>>chunk_rest;
321
    iss>>hex>>chunk_rest;
322
  }
322
  }
323
323
324
  shared_ptr<stream_socket> sock;
324
  pfi::lang::shared_ptr<stream_socket> sock;
325
325
326
  int chunk_rest;
326
  int chunk_rest;
327
327
Lines 334-340 Link Here
334
public:
334
public:
335
  typedef C char_type;
335
  typedef C char_type;
336
336
337
  basic_httpbody_streambuf(shared_ptr<stream_socket> sock, int length)
337
  basic_httpbody_streambuf(pfi::lang::shared_ptr<stream_socket> sock, int length)
338
    : sock(sock)
338
    : sock(sock)
339
    , rest(length)
339
    , rest(length)
340
    , buf(T::eof()){
340
    , buf(T::eof()){
Lines 359-365 Link Here
359
  }
359
  }
360
360
361
private:
361
private:
362
  shared_ptr<stream_socket> sock;
362
  pfi::lang::shared_ptr<stream_socket> sock;
363
363
364
  int rest;
364
  int rest;
365
  int buf;
365
  int buf;
Lines 368-374 Link Here
368
template <class C, class T=char_traits<C> >
368
template <class C, class T=char_traits<C> >
369
class basic_httpbody_chunked_stream : public basic_iostream<C,T>{
369
class basic_httpbody_chunked_stream : public basic_iostream<C,T>{
370
public:
370
public:
371
  basic_httpbody_chunked_stream(shared_ptr<stream_socket> sock)
371
  basic_httpbody_chunked_stream(pfi::lang::shared_ptr<stream_socket> sock)
372
    : basic_iostream<C,T>()
372
    : basic_iostream<C,T>()
373
    , buf(sock){
373
    , buf(sock){
374
    this->init(&buf);
374
    this->init(&buf);
Lines 380-386 Link Here
380
template <class C, class T=char_traits<C> >
380
template <class C, class T=char_traits<C> >
381
class basic_httpbody_stream : public basic_iostream<C,T>{
381
class basic_httpbody_stream : public basic_iostream<C,T>{
382
public:
382
public:
383
  basic_httpbody_stream(shared_ptr<stream_socket> sock, int len)
383
  basic_httpbody_stream(pfi::lang::shared_ptr<stream_socket> sock, int len)
384
    : basic_iostream<C,T>()
384
    : basic_iostream<C,T>()
385
    , buf(sock, len){
385
    , buf(sock, len){
386
    this->init(&buf);
386
    this->init(&buf);
Lines 406-412 Link Here
406
{
406
{
407
}
407
}
408
408
409
request::request(shared_ptr<stream_socket> sock)
409
request::request(pfi::lang::shared_ptr<stream_socket> sock)
410
  : method_("")
410
  : method_("")
411
  , uri_("/")
411
  , uri_("/")
412
  , version_(1,1)
412
  , version_(1,1)
Lines 438-448 Link Here
438
438
439
  // body
439
  // body
440
  if (cicmp(header_["Transfer-Encoding"],"chunked"))
440
  if (cicmp(header_["Transfer-Encoding"],"chunked"))
441
    stream=shared_ptr<iostream>(new basic_httpbody_chunked_stream<char>(sock));
441
    stream=pfi::lang::shared_ptr<iostream>(new basic_httpbody_chunked_stream<char>(sock));
442
  else if (header_["Content-Length"]!="")
442
  else if (header_["Content-Length"]!="")
443
    stream=shared_ptr<iostream>(new basic_httpbody_stream<char>(sock, lexical_cast<int>(header_["Content-Length"])));
443
    stream=pfi::lang::shared_ptr<iostream>(new basic_httpbody_stream<char>(sock, lexical_cast<int>(header_["Content-Length"])));
444
  else
444
  else
445
    stream=shared_ptr<iostream>(new socketstream(sock));
445
    stream=pfi::lang::shared_ptr<iostream>(new socketstream(sock));
446
}
446
}
447
447
448
request::~request()
448
request::~request()
Lines 474-480 Link Here
474
  return *stream;
474
  return *stream;
475
}
475
}
476
476
477
void request::send(shared_ptr<stream_socket> sock)
477
void request::send(pfi::lang::shared_ptr<stream_socket> sock)
478
{
478
{
479
  stringstream *ss=dynamic_cast<stringstream*>(stream.get());
479
  stringstream *ss=dynamic_cast<stringstream*>(stream.get());
480
  if (!ss) throw http_exception("body is not stringstream");
480
  if (!ss) throw http_exception("body is not stringstream");
Lines 499-505 Link Here
499
  if (sock->flush()>=0)
499
  if (sock->flush()>=0)
500
    throw http_exception("flush failed");
500
    throw http_exception("flush failed");
501
  if (dat.length()==0)
501
  if (dat.length()==0)
502
    stream=shared_ptr<iostream>(new socketstream(sock));
502
    stream=pfi::lang::shared_ptr<iostream>(new socketstream(sock));
503
}
503
}
504
504
505
response::response()
505
response::response()
Lines 518-524 Link Here
518
{
518
{
519
}
519
}
520
520
521
response::response(shared_ptr<stream_socket> sock)
521
response::response(pfi::lang::shared_ptr<stream_socket> sock)
522
{
522
{
523
  // status-line
523
  // status-line
524
  {
524
  {
Lines 546-556 Link Here
546
546
547
  // body
547
  // body
548
  if (cicmp(header_["Transfer-Encoding"],"chunked"))
548
  if (cicmp(header_["Transfer-Encoding"],"chunked"))
549
    stream=shared_ptr<iostream>(new basic_httpbody_chunked_stream<char>(sock));
549
    stream=pfi::lang::shared_ptr<iostream>(new basic_httpbody_chunked_stream<char>(sock));
550
  else if (header_["Content-Length"]!="")
550
  else if (header_["Content-Length"]!="")
551
    stream=shared_ptr<iostream>(new basic_httpbody_stream<char>(sock, lexical_cast<int>(header_["Content-Length"])));
551
    stream=pfi::lang::shared_ptr<iostream>(new basic_httpbody_stream<char>(sock, lexical_cast<int>(header_["Content-Length"])));
552
  else
552
  else
553
    stream=shared_ptr<iostream>(new socketstream(sock));
553
    stream=pfi::lang::shared_ptr<iostream>(new socketstream(sock));
554
}
554
}
555
555
556
response::~response()
556
response::~response()
Lines 582-588 Link Here
582
  return *stream;
582
  return *stream;
583
}
583
}
584
584
585
void response::send(shared_ptr<stream_socket> sock)
585
void response::send(pfi::lang::shared_ptr<stream_socket> sock)
586
{
586
{
587
  stringstream *ss=dynamic_cast<stringstream*>(stream.get());
587
  stringstream *ss=dynamic_cast<stringstream*>(stream.get());
588
  if (!ss) throw http_exception("body is not stringstream");
588
  if (!ss) throw http_exception("body is not stringstream");
Lines 607-613 Link Here
607
  if (sock->flush()>=0)
607
  if (sock->flush()>=0)
608
    throw http_exception("flush failed");
608
    throw http_exception("flush failed");
609
  if (dat.length()==0)
609
  if (dat.length()==0)
610
    stream=shared_ptr<iostream>(new socketstream(sock));
610
    stream=pfi::lang::shared_ptr<iostream>(new socketstream(sock));
611
}
611
}
612
612
613
} // http
613
} // http
(-)pficommon-1.3.1.0.old/src/network/mprpc/rpc_server.cpp (-2 / +2 lines)
Lines 80-88 Link Here
80
	if (!basic_server::create(port))
80
	if (!basic_server::create(port))
81
		return false;
81
		return false;
82
82
83
	std::vector<shared_ptr<thread> > ths(nthreads);
83
	std::vector<pfi::lang::shared_ptr<thread> > ths(nthreads);
84
	for (int i=0; i<nthreads; i++) {
84
	for (int i=0; i<nthreads; i++) {
85
		ths[i] = shared_ptr<thread>(new thread(
85
		ths[i] = pfi::lang::shared_ptr<thread>(new thread(
86
					pfi::lang::bind(&rpc_server::process, this)));
86
					pfi::lang::bind(&rpc_server::process, this)));
87
		if (!ths[i]->start()) return false;
87
		if (!ths[i]->start()) return false;
88
	}
88
	}
(-)pficommon-1.3.1.0.old/src/network/rpc/base.cpp (-9 / +9 lines)
Lines 59-78 Link Here
59
{
59
{
60
}
60
}
61
61
62
void rpc_server::add(const string &name, shared_ptr<invoker_base> invoker)
62
void rpc_server::add(const string &name, pfi::lang::shared_ptr<invoker_base> invoker)
63
{
63
{
64
  funcs[name]=invoker;
64
  funcs[name]=invoker;
65
}
65
}
66
66
67
bool rpc_server::serv(uint16_t port, int nthreads)
67
bool rpc_server::serv(uint16_t port, int nthreads)
68
{
68
{
69
  shared_ptr<server_socket, threading_model::multi_thread> ssock(new server_socket());
69
  pfi::lang::shared_ptr<server_socket, threading_model::multi_thread> ssock(new server_socket());
70
  if (!ssock->create(port))
70
  if (!ssock->create(port))
71
    return false;
71
    return false;
72
72
73
  vector<shared_ptr<thread> > ths(nthreads);
73
  vector<pfi::lang::shared_ptr<thread> > ths(nthreads);
74
  for (int i=0; i<nthreads; i++){
74
  for (int i=0; i<nthreads; i++){
75
    ths[i]=shared_ptr<thread>(new thread(bind(&rpc_server::process, this, ssock)));
75
    ths[i]=pfi::lang::shared_ptr<thread>(new thread(bind(&rpc_server::process, this, ssock)));
76
    if (!ths[i]->start()) return false;
76
    if (!ths[i]->start()) return false;
77
  }
77
  }
78
  for (int i=0; i<nthreads; i++)
78
  for (int i=0; i<nthreads; i++)
Lines 80-89 Link Here
80
  return true;
80
  return true;
81
}
81
}
82
82
83
void rpc_server::process(shared_ptr<server_socket, threading_model::multi_thread> ssock)
83
void rpc_server::process(pfi::lang::shared_ptr<server_socket, threading_model::multi_thread> ssock)
84
{
84
{
85
  for (;;){
85
  for (;;){
86
    shared_ptr<stream_socket> sock(ssock->accept());
86
    pfi::lang::shared_ptr<stream_socket> sock(ssock->accept());
87
    if (!sock) continue;
87
    if (!sock) continue;
88
    sock->set_nodelay(true);
88
    sock->set_nodelay(true);
89
89
Lines 139-149 Link Here
139
{
139
{
140
}
140
}
141
141
142
shared_ptr<socketstream> rpc_client::get_connection()
142
pfi::lang::shared_ptr<socketstream> rpc_client::get_connection()
143
{
143
{
144
  for (int i=0;i<2;i++){
144
  for (int i=0;i<2;i++){
145
    if (!ss || !(*ss)){
145
    if (!ss || !(*ss)){
146
      ss=shared_ptr<socketstream>(new socketstream(host, port));
146
      ss=pfi::lang::shared_ptr<socketstream>(new socketstream(host, port));
147
      if (!(*ss)){
147
      if (!(*ss)){
148
	ss.reset();
148
	ss.reset();
149
	continue;
149
	continue;
Lines 180-186 Link Here
180
  return ss;
180
  return ss;
181
}
181
}
182
182
183
void rpc_client::return_connection(shared_ptr<socketstream> css)
183
void rpc_client::return_connection(pfi::lang::shared_ptr<socketstream> css)
184
{
184
{
185
  ss=css;
185
  ss=css;
186
}
186
}
(-)pficommon-1.3.1.0.old/src/network/socket.cpp (-4 / +4 lines)
Lines 57-63 Link Here
57
namespace pfi{
57
namespace pfi{
58
namespace network{
58
namespace network{
59
59
60
shared_ptr<dns_resolver, threading_model::multi_thread> stream_socket::resolver;
60
pfi::lang::shared_ptr<dns_resolver, threading_model::multi_thread> stream_socket::resolver;
61
r_mutex stream_socket::resolver_m;
61
r_mutex stream_socket::resolver_m;
62
62
63
class sigign{
63
class sigign{
Lines 87-93 Link Here
87
  close();
87
  close();
88
}
88
}
89
89
90
void stream_socket::set_dns_resolver(shared_ptr<dns_resolver, threading_model::multi_thread> r)
90
void stream_socket::set_dns_resolver(pfi::lang::shared_ptr<dns_resolver, threading_model::multi_thread> r)
91
{
91
{
92
  synchronized(resolver_m)
92
  synchronized(resolver_m)
93
    resolver=r;
93
    resolver=r;
Lines 105-114 Link Here
105
      return false;
105
      return false;
106
  }
106
  }
107
107
108
  shared_ptr<dns_resolver, threading_model::multi_thread> res;
108
  pfi::lang::shared_ptr<dns_resolver, threading_model::multi_thread> res;
109
  synchronized(resolver_m){
109
  synchronized(resolver_m){
110
    if (!resolver)
110
    if (!resolver)
111
      set_dns_resolver(shared_ptr<dns_resolver, threading_model::multi_thread>
111
      set_dns_resolver(pfi::lang::shared_ptr<dns_resolver, threading_model::multi_thread>
112
		       (new normal_dns_resolver()));
112
		       (new normal_dns_resolver()));
113
    res=resolver;
113
    res=resolver;
114
  }
114
  }
(-)pficommon-1.3.1.0.old/src/visualization/magick.cpp (-3 / +3 lines)
Lines 69-77 Link Here
69
    Magick::PixelPacket c=img.pixelColor(x, y);
69
    Magick::PixelPacket c=img.pixelColor(x, y);
70
    // Quantum Depth is 8 or 16
70
    // Quantum Depth is 8 or 16
71
#if QuantumDepth == 16
71
#if QuantumDepth == 16
72
    r=c.red>>8;
72
    r=((unsigned char) c.red)>>8;
73
    g=c.green>>8;
73
    g=((unsigned char) c.green)>>8;
74
    b=c.blue>>8;
74
    b=((unsigned char) c.blue)>>8;
75
#else
75
#else
76
    r=c.red;
76
    r=c.red;
77
    g=c.green;
77
    g=c.green;
(-)pficommon-1.3.1.0.old/tools/genrpc/gen_php.h (-4 / +4 lines)
Lines 18-24 Link Here
18
18
19
#define LIB_PATH "pfi_rpc.php"
19
#define LIB_PATH "pfi_rpc.php"
20
20
21
typedef shared_ptr<type_rep> type_rep_p;
21
typedef pfi::lang::shared_ptr<type_rep> type_rep_p;
22
typedef pair<type_rep_p, vector<type_rep_p> > function_type;
22
typedef pair<type_rep_p, vector<type_rep_p> > function_type;
23
23
24
class php_generator{
24
class php_generator{
Lines 99-105 Link Here
99
      os<<"  var $int_typeinfo;"<<endl;
99
      os<<"  var $int_typeinfo;"<<endl;
100
      os<<"  var $string_typeinfo;"<<endl;
100
      os<<"  var $string_typeinfo;"<<endl;
101
      
101
      
102
      for (map<string, pair<shared_ptr<type_rep>, vector<shared_ptr<type_rep> > > >::iterator p=mems.begin();
102
      for (map<string, pair<pfi::lang::shared_ptr<type_rep>, vector<pfi::lang::shared_ptr<type_rep> > > >::iterator p=mems.begin();
103
	   p!=mems.end(); p++){
103
	   p!=mems.end(); p++){
104
	const string &method_name=p->first;
104
	const string &method_name=p->first;
105
	
105
	
Lines 113-119 Link Here
113
      os<<"    $this->int_typeinfo=new int_type(false, 4);"<<endl;
113
      os<<"    $this->int_typeinfo=new int_type(false, 4);"<<endl;
114
      os<<"    $this->string_typeinfo=new string_type();"<<endl;
114
      os<<"    $this->string_typeinfo=new string_type();"<<endl;
115
      
115
      
116
      for (map<string, pair<shared_ptr<type_rep>, vector<shared_ptr<type_rep> > > >::iterator p=mems.begin();
116
      for (map<string, pair<pfi::lang::shared_ptr<type_rep>, vector<pfi::lang::shared_ptr<type_rep> > > >::iterator p=mems.begin();
117
	   p!=mems.end(); p++){
117
	   p!=mems.end(); p++){
118
	const string &method_name=p->first;
118
	const string &method_name=p->first;
119
	
119
	
Lines 148-154 Link Here
148
      os<<"      throw new Exception(\"result code is not OK: $code\");"<<endl;
148
      os<<"      throw new Exception(\"result code is not OK: $code\");"<<endl;
149
      os<<"  }"<<endl;
149
      os<<"  }"<<endl;
150
      
150
      
151
      for (map<string, pair<shared_ptr<type_rep>, vector<shared_ptr<type_rep> > > >::iterator p=mems.begin();
151
      for (map<string, pair<pfi::lang::shared_ptr<type_rep>, vector<pfi::lang::shared_ptr<type_rep> > > >::iterator p=mems.begin();
152
	   p!=mems.end(); p++){
152
	   p!=mems.end(); p++){
153
	const string &method_name=p->first;
153
	const string &method_name=p->first;
154
	
154
	
(-)pficommon-1.3.1.0.old/tools/genrpc/main.cpp (-2 / +2 lines)
Lines 26-37 Link Here
26
  string tname("genrpctmpXXXXXX");
26
  string tname("genrpctmpXXXXXX");
27
  string gname("genrpcexeXXXXXX");
27
  string gname("genrpcexeXXXXXX");
28
  {
28
  {
29
    shared_ptr<ostream> pofs(tmpstream(tname));
29
    pfi::lang::shared_ptr<ostream> pofs(tmpstream(tname));
30
    ostream &ofs=*pofs.get();
30
    ostream &ofs=*pofs.get();
31
    ofs<<source_code;
31
    ofs<<source_code;
32
  }
32
  }
33
  {
33
  {
34
    shared_ptr<ostream> pofs(tmpstream(gname));
34
    pfi::lang::shared_ptr<ostream> pofs(tmpstream(gname));
35
  }
35
  }
36
  int compile_stat=system(("g++ -xc++ "+tname+" "+compiler_options+" -lpficommon -o "+gname).c_str());
36
  int compile_stat=system(("g++ -xc++ "+tname+" "+compiler_options+" -lpficommon -o "+gname).c_str());
37
  unlink(tname.c_str());
37
  unlink(tname.c_str());

Return to bug 596078