Esempio n. 1
0
void netat_hangup(void)
{
  if (sockets[0].s_state != SS_UNUSED) {
    sockets[0].s_state = SS_CLOSED;
    sockets[0].s_error = EPIPE;
    wakeup_all();
  }
}
Esempio n. 2
0
static uint8_t status(struct socket *s)
{
	uint8_t st;
	netstat = s->s_num;
	st = netstat;
	if (st & 0x43) {	/* Read, write or EOF */
		if (st & 0x02) {
			if (s->s_state == SS_CONNECTING) {
				s->s_state = SS_CONNECTED;
			        wakeup(s);
                        }
			if (s->s_iflag & SI_THROTTLE) {
				s->s_iflag &= SI_THROTTLE;
				wakeup(&s->s_data);
			}
		}
		if ((st & 0x40) && (s->s_state == SS_CONNECTED)) {
			s->s_state = SS_CLOSEWAIT;
                        wakeup(s);
                }
		/* EOF also wakes a read */
		if ((st & 0x01) && !(s->s_iflag & SI_DATA)) {
			s->s_iflag |= SI_DATA;
			wakeup(&s->s_iflag);
		}
	}
	if (st & 0x80) {
		s->s_error = netctrl;
                if (s->s_error <= sizeof(errormap))
        		s->s_error = errormap[s->s_error];
                else
                        s->s_error = EINVAL;
		if (s->s_state >= SS_CONNECTING) {
		        switch(s->s_error) {
		        case EINPROGRESS:
		        case ENOTCONN:
		                s->s_error = 0;
		                break;
                        default:
                		s->s_state = SS_CLOSED;
	                	wakeup_all(s);
                        }
		}
	}
	return st;
}
Esempio n. 3
0
		void send( runtime_node* n )
		{
			typename mutex::scoped_lock g(m_);
			del_.clear();

			//find the node
			typename nodes::iterator it;
			for( it = n_.begin(); it != n_.end(); ++it )
			{
				if( it->second.get() == n )
					break;
			}
			if( it == n_.end() )
				assert( 0 ); //node not found

			send_[n]=it->second;
			wakeup_all();
		}
Esempio n. 4
0
void
rumpuser_rw_exit(struct rumpuser_rw *rw)
{

	if (rw->o) {
		rw->o = NULL;
	} else {
		rw->v--;
	}

	/* standard procedure, don't let readers starve out writers */
	if (!TAILQ_EMPTY(&rw->wwait)) {
		if (rw->o == NULL)
			wakeup_one(&rw->wwait);
	} else if (!TAILQ_EMPTY(&rw->rwait) && rw->o == NULL) {
		wakeup_all(&rw->rwait);
	}
}
Esempio n. 5
0
error_t rwlock_unlock(struct rwlock_s *rwlock)
{
	register error_t err = 0;
	uint_t irq_state;

	//spinlock_lock(&rwlock->lock);
	mcs_lock(&rwlock->lock, &irq_state);

	if(rwlock->count == 0)
	{
		printk(ERROR, "ERROR: Unexpected rwlock_unlock\n");
		err = EPERM;
		goto fail_eperm;
	}
  
	if(rwlock->count > 1)  /* caller is a reader and no waiting writers */
	{
		rwlock->count --; 
		goto unlock_end;
	}

	/* We are the last reader or a writer */
	rwlock->count = 0;

	if((wakeup_one(&rwlock->wr_wait_queue, WAIT_FIRST)))
	{
		rwlock->count --;
		goto unlock_end;
	}

	/* No pending writer was found */
	rwlock->count += wakeup_all(&rwlock->rd_wait_queue);
  
fail_eperm:
unlock_end:
	//spinlock_unlock(&rwlock->lock);
	mcs_unlock(&rwlock->lock, irq_state);
	return err;
}
Esempio n. 6
0
arg_t net_shutdown(struct socket *s, uint8_t flag)
{
        s->s_iflag |= flag;
        wakeup_all(s);
        return 0;
}
Esempio n. 7
0
void
rumpuser_cv_broadcast(struct rumpuser_cv *cv)
{

	wakeup_all(&cv->waiters);
}