예제 #1
0
OPJ_BOOL associate_channel( query_param_t    query_param, 
			sessionlist_param_t *sessionlist,
			session_param_t **cursession, 
			channel_param_t **curchannel)
{
  if( search_session_and_channel( query_param.cid, sessionlist, cursession, curchannel)){
    
    if( !query_param.cnew)
      set_channel_variable_param( query_param, *curchannel);
  }
  else{
    fprintf( FCGI_stderr, "Error: process canceled\n");
    return OPJ_FALSE;
  }
  return OPJ_TRUE;
}
channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxtrans, cachemodel_param_t *cachemodel, channellist_param_t *channellist)
{
  channel_param_t *channel;
  const char transport[4][10] = { "non", "http", "http-tcp", "http-udp"};
  
  if( !cachemodel){
    fprintf( FCGI_stdout, "Status: 404\r\n"); 
    fprintf( FCGI_stdout, "Reason: cnew cancelled\r\n"); 
    return NULL;
  }

  channel = (channel_param_t *)opj_malloc( sizeof(channel_param_t));
  channel->cachemodel = cachemodel;

  /* set channel ID and get present time */
  snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());
  
  channel->aux = query_param.cnew;
  
  /* only tcp implemented for now */
  if( channel->aux == udp)
    channel->aux = tcp;
  
  channel->next=NULL;

  set_channel_variable_param( query_param, channel);

  if( channellist->first != NULL)
    channellist->last->next = channel;
  else
    channellist->first = channel;
  channellist->last = channel;
  
  fprintf( FCGI_stdout, "JPIP-cnew: cid=%s", channel->cid);
  fprintf( FCGI_stdout, ",transport=%s", transport[channel->aux]);
  
  if( channel->aux == tcp || channel->aux == udp)
    fprintf( FCGI_stdout, ",auxport=%d", channel->aux==tcp ? auxtrans.tcpauxport : auxtrans.udpauxport);

  fprintf( FCGI_stdout, "\r\n");

  return channel;
}