Exemplo n.º 1
0
uint32_t AmlUart::ReadStateAndNotify() {
    fbl::AutoLock al(&status_lock_);

    auto status = Status::Get().ReadFrom(&mmio_);

    uint32_t state = 0;
    if (!status.rx_empty()) {
        state |= SERIAL_STATE_READABLE;
    }
    if (!status.tx_full()) {
        state |= SERIAL_STATE_WRITABLE;
    }
    const bool notify = (state != state_);
    state_ = state;

    if (notify && notify_cb_) {
        notify_cb_(state);
    }

    return state;
}
Exemplo n.º 2
0
const char *util_get_mymac()
{
	AutoLock al(_lock);

	char *p = getenv("zonekey_my_mac");
	if (p)
		return p;

	static std::string _mac;
	if (_mac.empty()) {
		std::vector < NetInf > nis;
		get_all_netinfs(nis);
		if (nis.size() > 0) {
			_mac = nis[0].macaddr;
		}
	}

	if (_mac.empty())
		_mac = "000000000000";
	return _mac.c_str();
}
Exemplo n.º 3
0
/*virtual*/ SysStatus
FileLinuxPacket::bind(const char* addr, uval addrLen)
{
    SysStatus rc;
    AutoLock<LockType> al(&objLock); // locks now, unlocks on return
    uval len = addrLen;
    char *buf = (char*)allocGlobal(len);
    memcpy(buf, addr, addrLen);
    rc = sps._bind(buf, addrLen);
    if (_SUCCESS(rc)) {
	if (local) {
	    freeGlobal(local, localLen);
	}
	local = buf;
	localLen = addrLen;
    } else {
	freeGlobal(buf, len);
    }
    return rc;

}
Exemplo n.º 4
0
/*virtual*/ SysStatus
DispatcherMgr::publishProgInfo(ProcessID procID, char *name)
{
    AutoLock<LockType> al(&lock);	// locks now, unlocks on return

    /*
     * Program info is stored in the Dispatcher base class, not in the
     * DispatcherDefault extension (where the "published" structure resides),
     * so we can't use the locked_publish() machinery.
     */

    for (RDNum rd = 0; rd < Scheduler::RDLimit; rd++) {
	for (VPNum vp = 0; vp < Scheduler::VPLimit; vp++) {
	    if (dispatcher[rd][vp] != NULL) {
		(dispatcher[rd][vp])->storeProgInfo(procID, name);
	    }
	}
    }

    return 0;
}
Exemplo n.º 5
0
void DesktopServerProto::readConfigSettings(BlockingGate *gate)
{
  ServerConfig *srvConf = Configurator::getInstance()->getServerConfig();

  // Log
  srvConf->setLogLevel(gate->readUInt32());

  // Polling
  srvConf->setPollingInterval(gate->readUInt32());
  srvConf->setGrabTransparentWindowsFlag(gate->readUInt8() != 0);

  srvConf->blockLocalInput(gate->readUInt8() != 0);
  srvConf->setLocalInputPriority(gate->readUInt8() != 0);
  srvConf->setLocalInputPriorityTimeout(gate->readUInt32());

  srvConf->enableRemovingDesktopWallpaper(gate->readUInt8() != 0);

  // Receive video class names
  AutoLock al(srvConf);
  size_t stringCount = gate->readUInt32();

  StringStorage tmpString;
  for (size_t i = 0; i < stringCount; i++) {
    gate->readUTF8(&tmpString);
    srvConf->getVideoClassNames()->push_back(tmpString);
  }
  // Receive video rects
  stringCount = gate->readUInt32();

  tmpString.setString(_T(""));
  for (size_t i = 0; i < stringCount; i++) {
    gate->readUTF8(&tmpString);
    srvConf->getVideoRects()->push_back(RectSerializer::toRect(&tmpString));
  }

  // Receive video recognition interval
  srvConf->setVideoRecognitionInterval(gate->readUInt32());
  // Receive socket timeout
  srvConf->setIdleTimeout(gate->readUInt32());
}
Exemplo n.º 6
0
void load_fields_from_fft(const CH_FFT& fft , Triangulation& T  ) {

  int Nb = fft.Nx();

  c_array vx = fft.field_vel_x();
  c_array vy = fft.field_vel_y();

  c_array al = fft.field_f();

  c_array pp = fft.field_p();

  for(F_v_it vit=T.vertices_begin();
      vit != T.vertices_end();
      vit++) {

    int nx = vit->nx.val();
    int ny = vit->ny.val();

    // "right" ordering 
    int i = ( Nb - 1 ) - ny ;
    int j = nx;

    // "wrong" ordering
    // int i = nx;
    // int j = ny;

    vit->alpha.set( real( al(i,j) ) );
    vit->p.set( real( pp(i,j) ) );

    // FLIPincr trick
    vit->Delta_U.set( Vector_2( real( vx(i,j) ) , real( vy(i,j) ) ) );

    // whole velocity
    // vit->U.set( Vector_2( real( vx(i,j) ) , real( vy(i,j) ) ) );

    //  TODO: return more fields (chem pot, pressure, force, etc)
  }

  return;
}
Exemplo n.º 7
0
qore_size_t SSH2Channel::write(ExceptionSink *xsink, const void *buf, qore_size_t buflen, int stream_id, int timeout_ms) {
   assert(buflen);

   AutoLocker al(parent->m);
   if (check_open(xsink))
      return -1;

   BlockingHelper bh(parent);
   
   qore_size_t b_sent = 0;
   while (true) {
      qore_offset_t rc;
      while (true) {
	 rc = libssh2_channel_write_ex(channel, stream_id, (char *)buf + b_sent, buflen - b_sent);
	 //printd(5, "SSH2Channel::write(len=%lu) buf=%p buflen=%lu stream_id=%d timeout_ms=%d rc=%ld b_sent=%lu\n", buflen - b_sent, buf, buflen, stream_id, timeout_ms, rc, b_sent);

	 if (rc && rc != LIBSSH2_ERROR_EAGAIN)
	    break;

	 rc = parent->waitSocketUnlocked(timeout_ms);
	 if (!rc) {
	    xsink->raiseException(SSH2CHANNEL_TIMEOUT, "write timeout after %dms writing %lu byte%s of %lu", timeout_ms, b_sent, b_sent == 1 ? "" : "s", buflen);
	    return -1;
	 }
	 if (rc < 0) {
	    xsink->raiseException("SSH2CHANNEL-WRITE-ERROR", strerror(errno));
	    return -1;
	 }
      }

      if (rc < 0)
	 parent->doSessionErrUnlocked(xsink);

      b_sent += rc;
      if (b_sent >= buflen)
	 break;	 
   }

   return b_sent;
}
Exemplo n.º 8
0
const char *util_get_nic_name()
{
	AutoLock al(_lock);

	char *p = getenv("zonekey_my_nic");
	if (p)
		return p;

	static std::string _nic_name;
	if (_nic_name.empty()) {
		std::vector < NetInf > nis;
		get_all_netinfs(nis);
		if (nis.size() > 0) {
			_nic_name = nis[0].name;
		}
	}

	if (_nic_name.empty())
		_nic_name = "unknown";

	return _nic_name.c_str();
}
Exemplo n.º 9
0
void PreviewWalk::binarySearchforYawRollPitch(const double& fRr, const double& fRl, Vector3<double>& equalAngles, double& rYawPitchAngle)
{
	double Bup = MAX_RHIPYAWPITCH, Bdown = MIN_RHIPYAWPITCH;
	double rYawPitch = 0, delta = 10000;
	int steps = 0;
	RotationMatrix Rr, Rl;
	Vector3<double> ar(0, -1, 1), al(0,1,-1);
	double RAnglesZ, LAnglesZ;
	double t1, t2;
	while(true){
		steps++;
		Rr = Kinematics::rodrigues(ar, rYawPitch);
		Rl = Kinematics::rodrigues(al, rYawPitch);
		RAnglesZ = Rr.getZAngle();
		LAnglesZ = Rl.getZAngle();
		t1 = (RAnglesZ- LAnglesZ);
		t2 = (fRr - fRl);
		delta = fabs(t1-t2);
		//printf("Got target angle: %.4f, delta: %.6f, steps cost: %d\n", rad2deg(rYawPitch), rad2deg(delta), steps);
		if(delta < STOP_DELTA || steps > STOP_STEPS ||
			(rYawPitch - MIN_RHIPYAWPITCH) <= deg2rad(1) || (MAX_RHIPYAWPITCH - rYawPitch) <= deg2rad(1))
			break;
		else{
			if( t1 < t2){
				Bdown = rYawPitch;
				Bup = Bup;
				rYawPitch = (Bdown + Bup)/2;
			}else{
				Bdown = Bdown;
				Bup = rYawPitch;
				rYawPitch = (Bdown + Bup)/2;
			}
		}
	}
	equalAngles =  Rr.getXYZAngles();
	equalAngles.y = - equalAngles.y;
	equalAngles.x = -equalAngles.x;
	rYawPitchAngle = rYawPitch;
}
Exemplo n.º 10
0
///Initializes at specified time point
void LevelLogic::init(float const time_ms) {
  mBuyTurret.load("./music/several_coins_placed_lightly_down_on_table.wav");
  //No-insert alive turrets by default
  for(auto& a:mAliveTurrets) a->init(time_ms);
  for(auto& a:mBuildingTurrets) std::get<0>(a).init(time_ms);
  for(auto& a:mEnemies) a->init(time_ms);
  //Insert paths
  mPaths.clear();
  for(Path const& p : mLevel->mAssociatedPaths) {
    PathLogic pl(&p, mDefensor, &mLevel->mMap);
    //pl.init(time_ms);
    mPaths.push_back(pl);
  }
  //Insert avalanchas
  mAvalanchas.clear();
  for(Avalancha const*const av : mLevel->mAvalanchas) {
    AvalanchaLogic al(av);
    al.init(time_ms);
    mAvalanchas.push_back(al);
  }
  this->mMap.init_and_load();
}
Exemplo n.º 11
0
void ThreadPool::Stop() {
    CAutoLock al(lockOp_);

    if (bRuning_) {
        bRuning_ = false;
//        con_.Broadcast();

        int threadCnt = threadvec_.size();
        
        for(int i = 0; i < threadCnt; i++)
        {
            sem_.post();
        }
        
        for (int i = 0; i < threadCnt; i++) {
            threadvec_[i]->Join();
            delete threadvec_[i];
        }

        threadvec_.clear();
    }
}
Exemplo n.º 12
0
bool ControlAppAuthenticator::authenticate(const UINT8 cryptPassword[8],
                                           const UINT8 challenge[8],
                                           const UINT8 response[8])
{
  AutoLock al(&m_authMutex);

  checkBeforeAuth();
  if (m_isBreaked) {
    return false;
  }

  VncPassCrypt passCrypt;
  passCrypt.updatePlain(cryptPassword);
  bool isAuthSucceed = passCrypt.challengeAndResponseIsValid(challenge,
                                                             response);

  if (!isAuthSucceed) {
    notifyAbAuthFailed();
  }

  return isAuthSucceed;
}
Exemplo n.º 13
0
void
build(Node *n)
{
	List *l;
	Node res;

	if(n == 0)
		return;

	switch(n->op) {
	case OLIST:
		build(n->left);
		build(n->right);
		return;
	default:
		expr(n, &res);
		l = al(res.type);
		l->Store = res.Store;
		*tail = l;
		tail = &l->next;	
	}
}
Exemplo n.º 14
0
int SSH2Channel::requestPty(ExceptionSink *xsink, const QoreString &term, const QoreString &modes, int width, int height, int width_px, int height_px, int timeout_ms) {
   AutoLocker al(parent->m);
   if (check_open(xsink))
      return -1;

   BlockingHelper bh(parent);

   int rc;
   while (true) {
      rc = libssh2_channel_request_pty_ex(channel, term.getBuffer(), term.strlen(), modes.strlen() ? modes.getBuffer() : 0, modes.strlen(), width, height, width_px, height_px);
      if (rc == LIBSSH2_ERROR_EAGAIN) {
	 if ((rc = parent->waitSocketUnlocked(xsink, SSH2CHANNEL_TIMEOUT, "SSH2CHANNEL-REQUESTPTY-ERROR", "SSH2Channel::requestPty", timeout_ms)))
	    break;
	 continue;
      }
      if (rc)
	 parent->doSessionErrUnlocked(xsink);
      break;
   }

   return rc;
}
Exemplo n.º 15
0
int SSH2Channel::shell(ExceptionSink *xsink, int timeout_ms) {
   AutoLocker al(parent->m);
   if (check_open(xsink))
      return -1;

   BlockingHelper bh(parent);

   int rc;
   while (true) {
      rc = libssh2_channel_shell(channel);
      if (rc == LIBSSH2_ERROR_EAGAIN) {
	 if ((rc = parent->waitSocketUnlocked(xsink, SSH2CHANNEL_TIMEOUT, "SSH2CHANNEL-SHELL-ERROR", "SSH2Channel::shell", timeout_ms)))
	    break;
	 continue;
      }
      if (rc)
	 parent->doSessionErrUnlocked(xsink);
      break;
   }

   return rc;
}
Exemplo n.º 16
0
int SSH2Channel::setenv(const char *name, const char *value, int timeout_ms, ExceptionSink *xsink) {
   AutoLocker al(parent->m);
   if (check_open(xsink))
      return -1;

   BlockingHelper bh(parent);

   int rc;
   while (true) {
      rc = libssh2_channel_setenv(channel, (char *)name, value);
      if (rc == LIBSSH2_ERROR_EAGAIN) {
	 if ((rc = parent->waitSocketUnlocked(xsink, SSH2CHANNEL_TIMEOUT, "SSH2CHANNEL-SETENV-ERROR", "SSH2Channel::setenv", timeout_ms)))
	    break;
	 continue;
      }
      if (rc)
	 parent->doSessionErrUnlocked(xsink);
      break;
   }

   return rc;
}
Exemplo n.º 17
0
int SSH2Channel::requestX11Forwarding(ExceptionSink *xsink, int screen_number, bool single_connection, const char *auth_proto, const char *auth_cookie, int timeout_ms) {
   AutoLocker al(parent->m);
   if (check_open(xsink))
      return -1;

   BlockingHelper bh(parent);

   //printd(5, "SSH2Channel::requestX11Forwarding() screen_no=%d, single=%s, ap=%s, ac=%s\n", screen_number, single_connection ? "true" : "false", auth_proto ? auth_proto : "n/a", auth_cookie ? auth_cookie : "n/a");
   int rc; 
   while (true) {
      rc = libssh2_channel_x11_req_ex(channel, (int)single_connection, auth_proto, auth_cookie, screen_number);
      if (rc == LIBSSH2_ERROR_EAGAIN) {
	 if ((rc = parent->waitSocketUnlocked(xsink, SSH2CHANNEL_TIMEOUT, "SSH2CHANNEL-REQUESTX11FORWARDING-ERROR", "SSH2Channel::requestX11Forwarding", timeout_ms)))
	    break;
	 continue;
      }
      if (rc < 0)
	 parent->doSessionErrUnlocked(xsink);
      break;
   }
   return rc;
}
Exemplo n.º 18
0
void
append(Node *r, Node *list, Node *val)
{
	List *l, *f;

	l = al(val->type);
	l->Store = val->Store;
	l->next = 0;

	r->op = OCONST;
	r->type = TLIST;

	if(list->l == 0) {
		list->l = l;
		r->l = l;
		return;
	}
	for(f = list->l; f->next; f = f->next)
		;
	f->next = l;
	r->l = list->l;
}
Exemplo n.º 19
0
void DesktopBaseImpl::sendUpdate()
{
  _ASSERT(m_updateHandler != 0);
  _ASSERT(m_extDeskTermListener != 0);
  _ASSERT(m_extUpdSendingListener != 0);

  if (!m_extUpdSendingListener->isReadyToSend()) {
    m_log->info(_T("nobody is ready for updates"));
    return;
  }
  UpdateContainer updCont;
  try {
    if (!m_fullReqRegion.isEmpty()) {
      m_log->info(_T("set full update request to UpdateHandler"));
      m_updateHandler->setFullUpdateRequested(&m_fullReqRegion);
    }

    m_log->info(_T("extracting updates from UpdateHandler"));
    m_updateHandler->extract(&updCont);
  } catch (Exception &e) {
    m_log->info(_T("WinDesktop::sendUpdate() failed with error:%s"),
               e.getMessage());
    m_extDeskTermListener->onAbnormalDesktopTerminate();
  }

  if (!updCont.isEmpty() || !m_fullReqRegion.isEmpty()) {
    m_log->info(_T("UpdateContainer is not empty.")
              _T(" Updates will be given to all."));
    m_extUpdSendingListener->onSendUpdate(&updCont,
                                          m_updateHandler->getFrameBuffer(),
                                          m_updateHandler->getCursorShape());
    m_log->info(_T("Updates have been given to all."));
    AutoLock al(&m_reqRegMutex);
    m_fullReqRegion.clear();
  } else {
    m_log->info(_T("UpdateContainer is empty"));
  }
}
Exemplo n.º 20
0
        void Zips::add(const unsigned char* data, unsigned int size)
        {
            MutexAutoLock al(_lock);

            zlib_filefunc_def ff;
            fill_memory_filefunc(&ff);

            zmemdata dta;
            dta.data = (char*)data;
            dta.size = size;

            unzFile zp = unzOpen2((const char*)&dta, &ff);
            OX_ASSERT(zp);
            if (!zp)
                return;


            zpitem item;
            item.handle = zp;
            _zps.push_back(item);

            read(zp);
        }
Exemplo n.º 21
0
void RfbClientManager::updateIpInBan(const StringStorage *ip, bool success)
{
  AutoLock al(&m_banListMutex);
  refreshBan();
  BanListIter it = m_banList.find(*ip);
  if (success) {
    if (it != m_banList.end()) {
      // Even if client is already banned!
      m_banList.erase(it);
    }
  } else {
    if (it != m_banList.end()) {
      // Increase ban count
      (*it).second.count += 1;
    } else {
      // Add new element to ban list with ban count == 0
      BanProp banProp;
      banProp.banFirstTime = DateTime::now();
      banProp.count = 0;
      m_banList[*ip] = banProp;
    }
  }
}
Exemplo n.º 22
0
/*virtual*/ SysStatus
FileLinuxPacket::connect(const char* addr, uval addrLen,
			 GenState &moreAvail, ThreadWait **tw)
{
    AutoLock<LockType> al(&objLock);

    if (remote) {
	freeGlobal(remote, remoteLen);
    }
    remote = (char*)allocGlobal(addrLen);
    remoteLen = addrLen;
    memcpy(remote, addr, addrLen);

    if (local) {
	freeGlobal(local, localLen);
    }
    localLen = sizeof(localaddr) + 1;
    local = (char*)allocGlobal(localLen);
    memcpy(local, localaddr, localLen);

    moreAvail = available;
    return 0;
}
Exemplo n.º 23
0
        void Zips::add(std::vector<char>& data)
        {
            MutexAutoLock al(_lock);

            zlib_filefunc_def ff;
            fill_memory_filefunc(&ff);

            zmemdata dta;
            dta.data = (char*)&data.front();
            dta.size = data.size();

            unzFile zp = unzOpen2((const char*)&dta, &ff);
            OX_ASSERT(zp);
            if (!zp)
                return;

            _zps.push_back(zpitem());
            zpitem& item = _zps.back();
            item.handle = zp;
            std::swap(item.data, data);

            read(zp);
        }
Exemplo n.º 24
0
void zkmcu_hlp_init()
{
	static bool _inited = false;
	static ost::Mutex _cs;
	
	ost::MutexLock al(_cs);

	if (!_inited) {
		ms_init();
		ortp_init();

		ortp_set_log_level_mask(ORTP_FATAL);

		zonekey_h264_source_register();
		zonekey_yuv_sink_register();
		zonekey_void_register();
		

		rtp_profile_set_payload(&av_profile, 100, &payload_type_h264);
		rtp_profile_set_payload(&av_profile, 110, &payload_type_speex_wb);
		rtp_profile_set_payload(&av_profile, 102, &payload_type_ilbc);
	}
}
Exemplo n.º 25
0
int SSH2Channel::subsystem(const char *command, int timeout_ms, ExceptionSink *xsink) {
   AutoLocker al(parent->m);
   if (check_open(xsink))
      return -1;

   BlockingHelper bh(parent);

   int rc;
   while (true) {
      rc = libssh2_channel_subsystem(channel, command);
      //printd(5, "SSH2Channel::subsystem() cmd=%s rc=%d\n", command, rc);
      if (rc == LIBSSH2_ERROR_EAGAIN) {
	 if ((rc = parent->waitSocketUnlocked(xsink, SSH2CHANNEL_TIMEOUT, "SSH2CHANNEL-SUBSYSTEM-ERROR", "SSH2Channel::subsystem", timeout_ms)))
	    break;
	 continue;
      }
      if (rc)
	 parent->doSessionErrUnlocked(xsink);
      break;
   }

   return rc;
}
Exemplo n.º 26
0
void LogLevelSender::execute()
{
  try {
    while (!isTerminating()) {
      m_sleeper.waitForEvent();
      OutputStream *outStream;
      bool updateAvailable;
      unsigned char logLevel;
      {
        AutoLock al(&m_updateMutex);
        outStream = m_outStream;
        updateAvailable = m_updateAvailable;
        m_updateAvailable = false;
        logLevel = m_logLevel;
      }
      if (outStream != 0 && updateAvailable) {
        DataOutputStream output(outStream);
        output.writeUInt8(logLevel);
      }
    }
  } catch (...) { // FIXME: Log this.
  }
}
Exemplo n.º 27
0
int alltnog(int* lag, std::string lagning) {
  if (*lag > 4 || lagning == "lagstiftning")
    return 16702;
  int lagring = *lag + 1;
  std::string* lagtolkning = new std::string("landning");
  int* lampa = aftonsol(lagring, lagtolkning);
  std::string landsdel("lapp");
  int landyta = aldrig(&lagring, landsdel);
  std::string lathund("ledning");
  int lax = annars(&lagring, lathund);
  std::string* legat = new std::string("lek");
  std::string legering = al(lagring, legat);
  std::string lektionssal("levat");
  int lera = allesammans(&lagring, lektionssal);
  std::string* leve = new std::string("lika");
  int* lie = ann(lagring, leve);
  std::string* likafullt = new std::string("liksom");
  int* likaledes = anhopning(lagring, likafullt);
  std::string likt("limerick");
  int lilja = allteftersom(&lagring, likt);
  int limpa(11755);
  return limpa;
} // alltnog
Exemplo n.º 28
0
const char *util_get_myip_real()
{
	AutoLock al(_lock);

	char *p = getenv("zonekey_my_ip_real");
	if (p)
		return p;

	static std::string _ip;
	if (_ip.empty()) {
		std::vector < NetInf > nis;
		get_all_netinfs(nis);
		if (nis.size() > 0) {
			if (nis[0].ips.size() > 0) {
				_ip = nis[0].ips[0];
			}
		}
	}

	if (_ip.empty())
		_ip = "000.000.000.000";
	return _ip.c_str();
}
Exemplo n.º 29
0
int Connection::on_writable()
{
	beyondy::auto_lock<typeof outlock_> al(outlock_);
	int retval;
	
	if (mrsp_ == NULL) {
		if ((mrsp_ = outq_.get(0)) == NULL) {
			// should not have such case
			SYSLOG_ERROR("%s is writable while outQ is empty", name());
			return 0;
		}

		mbs_ = mrsp_;
	}

	while (1) {
		if ((retval = do_send()) == 0) {
			// done all
			if ((mrsp_ = outq_.get(0)) != NULL) {
				mbs_ = mrsp_;
				continue;
			}

			return 0;
		}
		else if (retval == 1) {
			// do partial, wait next time
			return 1;
		}
		else {
			// something wrong
			return -1;
		}
	}

	return 0;
}
Exemplo n.º 30
0
/* virtual */ SysStatusUval
LinuxPTYServer::sendto(struct iovec* vec, uval veclen, uval flags,
		       const char *addr, uval addrLen, GenState &moreAvail, 
		       void *controlData, uval controlDataLen,
		       __XHANDLE xhandle)
{
    tassertMsg((controlDataLen == 0), "oops\n");
    AutoLock<LockType> al(&_lock);
    ClientData *cd = getClientData(xhandle);
    SysStatusUval rc = 0;
    ProcessLinux::LinuxInfo info;
    ProcessID pid = XHandleTrans::GetOwnerProcessID(xhandle);
    rc = DREFGOBJ(TheProcessLinuxRef)->getInfoNativePid(pid, info);
    tassertMsg(_SUCCESS(rc),
	       "Couldn't get info about k42 process 0x%lx\n", pid);

    PTYTaskInfo ptyTI(info.pid, info.pgrp, info.session, info.tty,
		      info.pid == info.session);
    LinuxEnv sc(SysCall, ptyTI.t);
    rc = 0;
    for (uval i = 0; i<veclen; ++i) {
	int nr = ttydev_write(oli, (char*)vec[i].iov_base,
			      vec[i].iov_len, &availMask);
	if (nr < 0) {
	    if (rc>0) break;
	    if (nr==-EWOULDBLOCK) break;
	    rc = _SERROR(2367, 0, -nr);
	    break;
	}
	rc += nr;
    }
    availMask = ttydev_poll(oli);
    calcAvailable(moreAvail);
    cd->setAvail(moreAvail);
    return rc;

}