// destroy removes all stored state, and returns a set of updates we need to
// dispatch to clean up the state on the remote end.
197991
func (s *sentFolderDownloadState) destroy() []protocol.FileDownloadProgressUpdate {
	updates := make([]protocol.FileDownloadProgressUpdate, 0, len(s.files))
	for name, info := range s.files {
		updates = append(updates, protocol.FileDownloadProgressUpdate{
			Name:       name,
			Version:    info.version,
			UpdateType: protocol.UpdateTypeForget,
		})
		delete(s.files, name)
	}
	return updates
}
929710
func (s *Semaphore) Destroy() error {
	// Hold the lock as we try to acquire
	s.l.Lock()
	defer s.l.Unlock()

	// Check if we already hold the semaphore
	if s.isHeld {
		return ErrSemaphoreHeld
	}

	// List for the semaphore
	kv := s.c.KV()
	pairs, _, err := kv.List(s.opts.Prefix, nil)
	if err != nil {
		return fmt.Errorf("failed to read prefix: %v", err)
	}

	// Find the lock pair, bail if it doesn't exist
	lockPair := s.findLock(pairs)
	if lockPair.ModifyIndex == 0 {
		return nil
	}
	if lockPair.Flags != SemaphoreFlagValue {
		return ErrSemaphoreConflict
	}

	// Decode the lock
	lock, err := s.decodeLock(lockPair)
	if err != nil {
		return err
	}

	// Prune the dead holders
	s.pruneDeadHolders(lock, pairs)

	// Check if there are any holders
	if len(lock.Holders) > 0 {
		return ErrSemaphoreInUse
	}

	// Attempt the delete
	didRemove, _, err := kv.DeleteCAS(lockPair, nil)
	if err != nil {
		return fmt.Errorf("failed to remove semaphore: %v", err)
	}
	if !didRemove {
		return ErrSemaphoreInUse
	}
	return nil
}
1015036
func (s *session) destroy(e error) {
	s.closeOnce.Do(func() {
		if nerr, ok := e.(net.Error); ok && nerr.Timeout() {
			s.logger.Errorf("Destroying session %s: %s", s.destConnID, e)
		} else {
			s.logger.Errorf("Destroying session %s with error: %s", s.destConnID, e)
		}
		s.sessionRunner.Remove(s.srcConnID)
		s.closeChan <- closeError{err: e, sendClose: false, remote: false}
	})
}
252176
func (vm *VM) Destroy() (err error) {
	err = vm.haltWithFlag(true)
	if err != nil {
		return err
	}
	if vm.Dst != "" {
		err = os.RemoveAll(vm.Dst)
		if err != nil {
			err = lvm.ErrDeletingVM
			return
		}
	}
	return
}
594542
func (env *environ) Destroy(ctx callcontext.ProviderCallContext) error {
	return env.withSession(ctx, func(env *sessionEnviron) error {
		return env.Destroy(ctx)
	})
}
1207729
func (p *StoragePool) Destroy() error {
	var err C.virError
	result := C.virStoragePoolDestroyWrapper(p.ptr, &err)
	if result == -1 {
		return makeError(&err)
	}
	return nil
}
547237
func (c *GoContext) Destroy() {
	c.Response.Destroy()
	c.Request.Destroy()
	if c.WebSocket != nil {
		c.WebSocket.Destroy()
		c.WebSocket = nil
	}
}
1162116
func (s *DirectMessageService) Destroy(id int64, params *DirectMessageDestroyParams) (*DirectMessage, *http.Response, error) {
	if params == nil {
		params = &DirectMessageDestroyParams{}
	}
	params.ID = id
	dm := new(DirectMessage)
	apiError := new(APIError)
	resp, err := s.sling.New().Post("destroy.json").BodyForm(params).Receive(dm, apiError)
	return dm, resp, relevantError(err, *apiError)
}
1164061
func (l *Lock) Destroy() error {
	// Hold the lock as we try to release
	l.l.Lock()
	defer l.l.Unlock()

	// Check if we already hold the lock
	if l.isHeld {
		return ErrLockHeld
	}

	// Look for an existing lock
	kv := l.c.KV()
	pair, _, err := kv.Get(l.opts.Key, nil)
	if err != nil {
		return fmt.Errorf("failed to read lock: %v", err)
	}

	// Nothing to do if the lock does not exist
	if pair == nil {
		return nil
	}

	// Check for possible flag conflict
	if pair.Flags != LockFlagValue {
		return ErrLockConflict
	}

	// Check if it is in use
	if pair.Session != "" {
		return ErrLockInUse
	}

	// Attempt the delete
	didRemove, _, err := kv.DeleteCAS(pair, nil)
	if err != nil {
		return fmt.Errorf("failed to remove lock: %v", err)
	}
	if !didRemove {
		return ErrLockInUse
	}
	return nil
}
547243
func (vm *VM) Destroy() error {
	err := vm.Halt()
	if err != nil {
		return err
	}

	// vbox will not release it's lock immediately after the stop
	time.Sleep(1 * time.Second)

	_, err = runner.RunCombinedError("unregistervm", vm.Name, "--delete")
	if err != nil {
		return lvm.WrapErrors(lvm.ErrDeletingVM, err)
	}
	return nil
}
764870
func (d *AllocDir) Destroy() error {
	// Unmount all mounted shared alloc dirs.
	var mErr multierror.Error
	if err := d.UnmountAll(); err != nil {
		mErr.Errors = append(mErr.Errors, err)
	}

	if err := os.RemoveAll(d.AllocDir); err != nil {
		mErr.Errors = append(mErr.Errors, fmt.Errorf("failed to remove alloc dir %q: %v", d.AllocDir, err))
	}

	// Unset built since the alloc dir has been destroyed.
	d.mu.Lock()
	d.built = false
	d.mu.Unlock()
	return mErr.ErrorOrNil()
}
1266352
func (vpcApi *VpcApi) Destroy(id string) (bool, error) {
	_, err := vpcApi.entityService.Delete(id, []byte{}, map[string]string{})
	return err == nil, err
}
875140
func (opts *Options) Destroy() {
	C.rocksdb_options_destroy(opts.c)
	if opts.ccmp != nil {
		C.rocksdb_comparator_destroy(opts.ccmp)
	}
	if opts.cst != nil {
		C.rocksdb_slicetransform_destroy(opts.cst)
	}
	if opts.ccf != nil {
		C.rocksdb_compactionfilter_destroy(opts.ccf)
	}
	opts.c = nil
	opts.env = nil
	opts.bbto = nil
}
477837
func (req *Request) Destroy() {
	req.In = nil
	req.ContentType = ""
	req.Format = ""
	req.AcceptLanguages = nil
	req.Method = ""
	req.RemoteAddr = ""
	req.Host = ""
	req.Header.Destroy()
	req.URL = nil
	req.Form = nil
	req.MultipartForm = nil
}
235589
func (ctx *CUContext) Destroy() error {
	err := result(C.cuCtxDestroy(ctx.ctx))
	*ctx = CUContext{}
	return err
}
815184
func (opts *TransactionOptions) Destroy() {
	C.rocksdb_transaction_options_destroy(opts.c)
	opts.c = nil
}
274580
func (dfs *DistributedFilesystem) Destroy(tenantID string) error {
	vol, err := dfs.disk.Get(tenantID)
	if err != nil {
		glog.Errorf("Error destroying DFS:  Could not get volume for tenant %s: %s", tenantID, err)
	} else {
		// Remove all the stuff we need a volume object for
		snapshots, err := vol.Snapshots()
		if err != nil {
			glog.Errorf("Could not get snapshots for tenant %s: %s", tenantID, err)
		} else {
			for _, snapshot := range snapshots {
				if err := dfs.Delete(snapshot); err != nil {
					glog.Errorf("Could not remove snapshot %s for tenant %s: %s", snapshot, tenantID, err)
				}
			}
		}

		if err := dfs.unexport(vol.Path()); err != nil {
			glog.Errorf("Could not unexport path %s: %s", vol.Path(), err)
		}
	}

	if err := dfs.deleteImages(tenantID, docker.Latest); err != nil {
		glog.Errorf("Could not delete images for tenant %s: %s", tenantID, err)
	}

	if err := dfs.disk.Remove(tenantID); err != nil {
		glog.Errorf("Could not remove application data for tenant %s: %s", tenantID, err)
		return err
	}

	return nil
}